Add the button response update_command_ui message on the toolbar and toolbar to the MFC dialog box.

Source: Internet
Author: User

Add the button response update_command_ui message in the toolbar and toolbar in the dialog box.

Adding a toolbar to a dialog box program is actually very simple. You can find many examples on the Internet. The general steps are as follows: 1. Add and process resources

Bar resources; 2. Define a toolbar variable in the dialog box class; 3. Create a toolbar in the oninitdialog function of the dialog box. Cheng

The order is as follows:
Define the toolbar member variables in the dialog box class:
Ctoolbar m_toolbar;
Create in the oninitdialog function:
If (! M_toolbar.createex (this, tbstyle_flat,

Ws_child | ws_visible | cbrs_top | cbrs_gripper | cbrs_tooltips | cbrs_size_dynamic)
|! M_toolbar.loadtoolbar (idr_toolbar_graphics ))
{
Trace0 (_ T ("failed to create a toolbar/N "));
Return false;
}
Repositionbars (afx_idw_controlbar_first, afx_idw_controlbar_last, 0 );

However, you need to make the toolbar in the dialog box respond to the update_command_ui message, so that only the reload of the press hold status is required.

Update_command_ui message and setcheck cannot be used, because the button attribute on the toolbar is a normal button, you can

Perform the following test:
If (m_toolbar.getbuttonstyle (0) = tbbs_button)
{
Afxmessagebox ("This Is button style ");
}
You must add the following settings:
M_toolbar.setbuttonstyle (0, tbbs_checkbox );
M_toolbar.setbuttonstyle (1, tbbs_checkbox );
The prototype of the setbuttonstyle Function and Its Related descriptions :( refer to msdn)
1. Void setbuttonstyle (INT nindex, uint nstyle );

Parameters

Nindex

Index of the button or separator whose information is to be set.

Nstyle

The button style. The following button styles are supported:

Tbbs_button standard Pushbutton (default)

Tbbs_separator Separator

Tbbs_checkbox auto check-box button

Tbbs_group marks the start of a group of buttons

Tbbs_checkgroup marks the start of a group of check-box buttons
Remarks

Call this member function to set the style of a button or separator, or to group buttons.

Button's style determines how the button appears and how it responds to user input.

2. There is also a function for modifying the button attribute.
Void setbuttoninfo (INT nindex, uint NID, uint nstyle, int iimage );

Parameters

Nindex

Index of the button or separator whose information is to be set.

Nid

The value to which the button's command ID is set.

Nstyle

The new button style. The following button styles are supported:

Tbbs_button standard Pushbutton (default)

Tbbs_separator Separator

Tbbs_checkbox auto check-box button

Tbbs_group marks the start of a group of buttons

Tbbs_checkgroup marks the start of a group of check-box buttons
Iimage

New Index for the button's image within the bitmap.

Remarks

Call this member function to set the button's command ID, style, and image number.

Separators, which have the style tbbs_separator, this function sets the separator's width in

Pixels to the value stored in iimage.

For information on bitmap images and buttons, see the ctoolbar overview and

Ctoolbar: loadbitmap.

 

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.