What makes me depressed all the time is that a small toolbar made me do this for four days. The code is not too much, but there are so few materials, I have not found any information about toolbar on csdn. Let me do it. I have checked the information over the past few days. Blow off the fuck, fuck, and MFC. It's really hard to make the interface look as good as it is. If C # is done in less than an hour, it will take so long, to find such information. Fuck and fuck. I have been using toolbar for five days, but I believe it will be useful to other things. As the saying goes, standing on the shoulders of giants is very high. I am not a giant, but in that direction.
Let's take a look at the simple toolbar.
This is a dialog box for creating a new project. Do not make a mistake.
Add these items to your header file.
Ctoolbar m_toolbar; // Toolbar
Cimagelist m_imagelist; // Image
Cstring STR; // character
Crebar m_rebar; // container class
Then you can write it in your oninitdialog.
The simplest toolbar tool.
M_imagelist.create (32, 32, ilc_color24 | ilc_mask, 1, 1 );
M_imagelist.add (afxgetapp ()-> loadicon (idi_icon1 ));
M_imagelist.add (afxgetapp ()-> loadicon (idi_icon2 ));
M_imagelist.add (afxgetapp ()-> loadicon (idi_icon3 ));
M_imagelist.add (afxgetapp ()-> loadicon (idi_icon4 ));
M_imagelist.add (afxgetapp ()-> loadicon (idi_icon5 ));
M_imagelist.add (afxgetapp ()-> loadicon (idi_icon6 ));
M_imagelist.add (afxgetapp ()-> loadicon (idi_icon7 ));
M_imagelist.add (afxgetapp ()-> loadicon (idi_icon8 ));
M_imagelist.add (afxgetapp ()-> loadicon (idi_icon9 ));
Let's define an array.
Uint array [9];
For (INT I = 0; I <9; I ++)
{
Array [I] = I + 1001;
}
M_toolbar.create (this );
M_toolbar.setbuttons (array, 9 );
M_toolbar.gettoolbarctrl (). setbuttonwidth (50, 70 );
M_toolbar.gettoolbarctrl (). setimagelist (& m_imagelist );
M_toolbar.setsizes (csize (70, 50), csize (28, 28 ));
M_toolbar.enabletooltips (true );
Repositionbars (afx_idw_controlbar_first, afx_idw_controlbar_last, 0 );
Let's take a look at the effect.
This is the effect. This is a simple toolbar. Add a little more knowledge to it. Add a separator to the back of the button?
Let me think about the fourth button.
Then let you change the above data to this.
Uint array [9];
For (INT I = 0; I <9; I ++)
{
If (I = 3)
Array [I] = id_separator // The fourth button is a separator. Note that the array subscript starts from 0.
Else
Array [I] = I + 1001;
}
Let's see how it works?
See the effect.
If you want to add text to him. Add these statements.
M_toolbar.setbuttontext (0, "system Logon ");
M_toolbar.setbuttontext (1, "operator information ");
M_toolbar.setbuttontext (2, "customer information ");
M_toolbar.setbuttontext (3, "goods warehouse receiving ");
M_toolbar.setbuttontext (4, "product sales ");
M_toolbar.setbuttontext (5, "sales return ");
M_toolbar.setbuttontext (6, "customer order ");
M_toolbar.setbuttontext (7, "warehouse receiving query ");
M_toolbar.setbuttontext (8, "sales query ");
Let's take a look at the effect.
It's easy to come here.
How can I change his font? I also found a lot of materials. You can see if there is any problem with this writing.
Logfont;
GetObject (: getstockobject (default_gui_font), sizeof (logfont), & logfont );
Logfont. lfcharset = gb2312_charset;
Logfont. lfweight = fw_normal;
Logfont. lfheight = 24;
Lstrcpy (logfont. lffacename, _ T (" "));
Static cfont sfontstatusbar;
Sfontstatusbar. createfontindirect (& logfont );
M_toolbar.setfont (& sfontstatusbar );
Well, let's take a look at the effect, because the icons are different from those above.
I can see that there is no font to change. As for how to change the font color, I will not do it now. I also hope you can see this blog article to help me solve it. Thank you. Although the icons are not very nice, they are made by yourself. I don't feel as miserable as I want.
As for how to add a background color to him, let's see how to write it.
M_toolbar.setsizes (csize (110,100), csize (60, 60 ));
M_rebar.create (this );
M_rebar.addbar (& m_toolbar );
M_rebar.redrawwindow ();
Rebarbandinfo Info;
Info. cbsize = sizeof (Info );
Info. fmask = rbbim_background;
M_toolbar.modifystyle (0, tbstyle_transparent );
Info. hbmback = loadbitmap (AfxGetInstanceHandle (), makeintresource (IDB _ bitmap2 ));
M_rebar.getrebarctrl (). setbandinfo (0, & info );
Let's take a look at the effect.
See it. This is what I do now, but I still hope to help others. Toolbar.
Here are a few examples for you to see the results.
This is a single document.
Let's take a look at the effect.
Another toolbar that can be moved is a single document.
Let's take a look at the next screenshot.
Okay. Let me give it to you.
Click Open Link
Click Open Link
Click Open Link
I hope this will help my friends who are working on development. I also hope that the experts can help me solve this problem. Do not change the color of the toolbar Font too much. Hope you can help me. I have written everything I know here. Hope you can help me. Thanks again. If it is changed, I will upload it to my resources so that you can write programs later.
Thank you again for helping me. Thank you here. The last step is to make you difficult. I have met you several times. I do not have much experience in development.