The Button response to the toolbar and the toolbar on the dialog box and the UPDATE_COMMAND_UI message adds the toolbar in the dialog program. It is very simple, and there are many examples available on the Internet. The general step is: 1, add a set of resources in the resource; 2. Define a toolbar variable in the dialog class; 3. In the CREATE toolbar in the dialog box.
Procedures are as follows: Customize Toolbar member variable in your dialog class: CToolBar m_ToolBar; Create it in 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 ( "create tools failed / n")); return FALSE;} RepositionBars (AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0); however make dialog toolbar UPDATE_COMMAND_UI response message, do To the state that holds only overloads the Update_Command_UI message and uses setCheck. Because the button property on the toolbar at this time is a normal button, you can test the following method: if (m_toolbar.getButtonStyle (0) == TBBS_BUTTON) {AfxMessageBox ( "This is Button Style");} must add the following settings: m_ToolBar.SetButtonStyle (0, TBBS_CHECKBOX); m_ToolBar.SetButtonStyle (1, TBBS_CHECKBOX); SetButtonStyle function prototype and related primers described :( since 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. A button's style determines how the button appears And How It Responds to User Input. 2, there is also a function of the Button property Void SetButtonInfo (Int Nindex, Uint Nid, Uint NStyle, Int iimage);