VC application-Customize your Toolbar

Source: Internet
Author: User

VC application-Customize your toolbar icon

I have seen an article on BBS over the past few days about using VC to design the True Color toolbar. In fact, if you often use VC, you will surely feel that the toolbar icon of VC is ugly. The method described below will make your Toolbar face-changing ~~ Because it was a long time ago article, and some things are not very easy to use. I tested it and improved some places. Below I will post the main steps and key content, I shared it with you. Pai_^

1. download a free tool that can create a true Color toolbar icon, called tbcreator. Csdn is too slow to upload files, and problems often occur. Therefore, you can go to Baidu and Google to find out more easily.
With this function, you can add the icons to be merged and automatically combine them into a real-Color toolbar bitmap. In addition, it can be split and combined again, and the front and back positions can be arranged again. Haha, in less than one minute, the BMP bitmap of a PP is complete. The normal and disabled graphs can also be generated simultaneously.

2. Download The ctruecolortoolbar class, which is a very practical class for creating a toolbar by loading a true color bitmap. Using this class with the above tools is a good combination. This class is: http://www.codeproject.com/docking/TrueColorToolBar.asp (the folder in this article contains a demo in the source file containing this class ).

3. Enter the familiar VC, create an MFC standard program, and add two files (one CPP file and one hfile) downloaded in 2 to the project. Then re-compile the program. At this time, a ctruecolortoolbar class is added.

4. Add the toolbar bitmap we have prepared to the program. tbcreator can generate both normal bitmap and diabled bitmap, as shown below:
One is a normal image and the other is a disable image:
Normal bitmap:

Disable bitmap:

Copy the two bitmap files to the res directory of the program, right-click the resource view, and import the two bitmaps using import. The program will automatically generate two IDs, of course, you can change the ID to idb_normal and idb_disable.
In this example, we can see that we want a toolbar assembled by 48 × 48 (the image resource we edited using tbcreator is 48 × 48 ). In this case, the tool bar automatically generated by the system is used. Find the idr_mainframe under the toolbar resource. Here, you can change the number of buttons as needed and delete unnecessary buttons. Now you need to add a 48x48 button, so you have to modify the button size (very important, otherwise you will only get the default 16x16 effect ).). Double-click any of the buttons to change the size to 48 × 48.

5. Find the member variable m_wndtoolbar of the program's cmainframe framework class, which is the tool bar variable.
The default ctoolbar class is used. You can change the ctoolbar to ctruecolortoolbar.
Include the header file in the file that references the ctruecolortoolbar class of the program. In this example, it starts with mainfrm. h and adds the following sentence: # include "truecolortoolbar. H"
Find the oncreate function of the cmainframe framework class of the program. This is where the toolbar is generated. Add the following statement here:
M_wndtoolbar.loadtruecolortoolbar (48,
Idb_normal,
Idb_normal,
IDB_DISABLED );
The three parameters indicate that 48 indicates that the size of the toolbar button is 48 × 48, the second is the normal toolbar bitmap ID, and the third is hot (normal ID can be used) the toolbar bitmap ID. The last one is the disable toolbar bitmap ID.
For more information about the added locations, see the sample code. Now you can compile and run the tool bar.

6. Finally, you can set the IDR_MAINFRAME toolbar button under the toolbar resource generated by the system, just like a general program, and compile the corresponding response function.
 

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.