Dynamic True Color Toolbar

Source: Internet
Author: User
Tags bool

The source code execution effect diagram is as follows:

and vckbase contact for a long, is always greedy to dig from the use of Dongdong, but did not think of their own things to share with people, very embarrassed.

Since my rangerchat point to point Chat tool in Vckbase, I have received letters from many friends. Many of them say that looking at so much code at once doesn't really know how to extract what they want from it. Now I have some good resources in the process of doing the project for you to judge. In the future, I will provide some good code and share with you. Thank you.

The first one: a toolbar with a dynamic true color icon, I believe you can add a lot to the application.

STEP1: Build a single document/Multiple document framework

STEP2: Add the following variable to the frame class CMainFrameCReBar m_wndReBar

STEP3: adding bool-member functions Createextoolbar ()

BOOL Cmainframe::createextoolbar ()
CImageList img;
CString str;
if (!m_wndrebar.create (this))
if (!m_wndtoolbar.createex (this, Tbstyle_flat, Ws_child | ws_visible | Cbrs_top
| Cbrs_tooltips | cbrs_flyby | cbrs_size_dynamic))
The following code sets the width and length of the button
M_wndtoolbar.gettoolbarctrl (). Setbuttonwidth (40, 80);
The following code is a bitmap that sets "hot"
Img. Create (ilc_color8|, the ilc_mask,2,2);
Img. SetBkColor (:: GetSysColor (Color_btnface));
Img. ADD (AfxGetApp ()->loadicon (Idi_icon_msg_getbutton));//0 Receiving letter
...//Omit the other button settings code, see this article provides the source codes
M_wndtoolbar.gettoolbarctrl (). SetHotImageList (&IMG);
Img. Detach ();
The following code is a bitmap that sets "cold"
Img. Create (ilc_color8|, Ilc_mask, 2,2);
Img. SetBkColor (:: GetSysColor (Color_btnface));
Img. ADD (AfxGetApp ()->loadicon (Idi_icon_msg_getbutton));//0 Receiving letter
Img. ADD (AfxGetApp ()->loadicon (IDI_ICON_MSG_WRITEMSGBTN));//1 Letter
...//Omit the other button settings code, see this article provides the source codes
M_wndtoolbar.gettoolbarctrl (). SetImageList (&IMG);
Img. Detach ();
changing properties
M_wndtoolbar.modifystyle (0, Tbstyle_flat | Cbrs_tooltips | Tbstyle_transparent| Tbbs_checkbox);
M_wndtoolbar.setbuttons (null,21);
Set up each toolbar button sets the text
M_wndtoolbar.setbuttoninfo (0, Idc_writemsg, Tbstyle_button, 1);
M_wndtoolbar.setbuttontext (0, "letter");
...//Omit the other button settings code, see this article provided the source
CRect Recttoolbar;
Get the size of the button
M_wndtoolbar.getitemrect (0, &recttoolbar);
To set the size of a button
M_wndtoolbar.setsizes (Recttoolbar.size (), CSize (20,20));
Add toolbar to Rebar
M_wndrebar.addbar (&m_wndtoolbar);
Change some properties
Rebarbandinfo Rbbi;
rbbi.cbsize = sizeof (Rbbi); This is a must fill
Rbbi.fmask = Rbbim_childsize | Rbbim_idealsize | rbbim_size| Rbbim_background;
Width of the tool bar
Rbbi.cxminchild = Recttoolbar.width ();
Rbbi.cyminchild = Recttoolbar.height ();
The following line of code is to add a background bitmap to the sidebar, please note the RBBIM_BACKGROUND flag in the Rbbi.fmask
Rbbi.hbmback = LoadBitmap (:: AfxGetInstanceHandle (), Makeintresource (Idb_toolbarbkmap));
rbbi.cx = Rbbi.cxideal = Recttoolbar.width () * 10;
M_wndrebar.getrebarctrl (). SetBandInfo (0, &rbbi);
return TRUE;
STEP4: Open the OnCreate () member function to add the following code

If (!this->CreateExToolBar())
   return -1;

and remove all previous operations (create, float) about toolbar.

The True Color Dynamic toolbar has been successfully created!

Here are some instructions:

No1: Each button in the toolbar has to be created manually (see source)

NO2: The ID and message processing for each button is to be added manually (this does not detail the process)

OK, let's try it again.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.