VC personalized menu and toolbar

Source: Internet
Author: User

Link: http://hi.baidu.com/chenfalei/blog/item/ed98bb7e5250353c0dd7da04.html

The effect is as follows:

The solution is as follows:

1. Set a placeholder in the corresponding position on the toolbar. The specific method is to find XXX. RC file, open it in text mode, find the code section of the toolbar resource, and add the separator directly (Note: This separator is used to represent the custom control)

2. Add a protected empty variable to the framework class where the toolbar is located. This control variable must encapsulate the object of the class for which the control is to be added.

Cedit m_myedit;

Apply for a unique and iconic orthopedic resource for this control variable, and add it at the end of the resource. h file.

# Define idc_myedit 1000

(Note: # DEFINE _ aps_next_control_value 1000 indicates that the next resource file that can be customized in the resource file is 1000. It is a good habit to add custom resources, copy this sentence to the end and change its value to indicate the next available value of 1001)

3. Set the position of the custom control and call the placeholder setting method in the oncreate () method of the framework class. If the tool bar variable is m_wndtoolbar, perform m_wndtoolbar.setbuttoninfo (index_m_myedit, id_idc_myedit, tbbs_separator, count_piex) to set the placeholder,

4. dynamically create the control and display it on the toolbar. You only need to call the CREATE () function of the control. For example

Crect rect;

M_wndtoolbar.getitemrect (index_m_myedit, & RExt );

M_myedit.create (ws_child | ws_visibal, rect, & m_wndtoolbar, idc_myedit );

The specific process is described above. If you want to implement more complex functions for custom controls, you can derive the controls in step 2 to implement more complex functions.

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.