Article ID: 115306
Article Last Modified on 11/21/2006
UINT iButtonID;
UINT iButtonStyle;
int iButtonImage;
// If the Toolbar is not based upon the default "AFX_IDW_TOOLBAR"
// constant, then replace its use with the valid Toolbar constant.
// If the following line is used from the Frame Window remove
//"GetParentFrame()->":
CToolBar* pBar =
(CToolBar*)GetParentFrame()->GetDescendantWindow(AFX_IDW_TOOLBAR);
// If this code sample is called from an AppWizard generated,
// Frame Window member function in Visual C++ 4.0, replace the above
// statement with the following. Recall that the CMDIFrameWnd-derived
// Frame Window generated by AppWizard has a CToolBar m_wndToolBar
// member.
CToolBar* pBar = &m_wndToolBar;
if (pBar != NULL) {
// Use the relevant Button ID for the following line:
int iButtonIndex = pBar->CommandToIndex(ID_MY_BUTTON);
pBar->GetButtonInfo(iButtonIndex, iButtonID, iButtonStyle,
iButtonImage);
// The following code checks for all possible states.
// In practice, check only for those states that you need.
if (iButtonStyle & TBBS_PRESSED)
// Button Down
else
if (iButtonStyle & (TBBS_CHECKED & TBBS_DISABLED))
// Button Down & Unavailable
else
if (iButtonStyle & TBBS_DISABLED)
// Button Disabled
else
if (iButtonStyle & TBBS_INDETERMINATE)
// Button State Indeterminate
else
if (iButtonStyle & TBBS_CHECKED)
// Button Checked
else
// Button Up & Enabled
}
Additional query words: 1.00 1.50 2.00 2.10 2.50 2.51 2.52 3.00 3.10 4.00 kbinf kbVC1500
Keywords: kbhowto kbtoolbar kbuidesign KB115306