Adding a toolbar and a toolbar on a toolbar and a toolbar in an MFC dialog program Update

xiaoxiao2021-03-06  54

Add the toolbar and the button response Update_command_ui message on the toolbar on the toolbar.

Add a toolbar in the dialog program is actually very simple, and there are many examples of online. The general step is: 1, add processing in resources

Tools in the dialog class; 3. 3, the Create toolbar in the dialog in the OnInitDialog function. Approach

The order is as follows: Define toolbar member variables in the dialog class: ctoolbar m_toolbar; 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 ( "create tools failed / n")); return FALSE;} RepositionBars (AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0) ;

However, let's make the toolbar in the dialog in response to the update_command_ui message, and the state that holds is only overloaded.

Update_command_ui messages and use setCheck, because the button properties on the toolbar at this time are normal buttons, you can

Tested by 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; the prototype of the setButtonStyle function and its related instructions: (from 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 AresuTed:

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 modifying the Button property Void SetButtonInfo (Int Nidence, 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 AresuTed:

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 Withnin The bitmap.

Remarks

Call this Member Function To Set The Button's Command ID, Style, And Image Number. For

Separators, Which Have The Style Tbbs_separator, this function sets the separator's width in

Pixels to the value stored in us.

For Information On Bitmap images and buttons, see the ctoolbar overview and

CToolbar :: loadingBitmap.

转载请注明原文地址:https://www.9cbs.com/read-91093.html

New Post(0)