First, join the toolbar
(!! M_wndToolBar.Create (this) || m_wndToolBar.LoadToolBar (IDR_TOOLBAR1)) if AfxMessageBox ( "create a toolbar failed"); else {// AfxMessageBox ( "OK"); CRect rect; GetClientRect (& rect); rect. Bottom = Rect.top 30; // 30 is the toolbar height m_wndtoolbar.movewindow designated;}
Second, set the enable / disable UINT style = m_wndToolBar.GetButtonStyle (1); if ((style & TBSTATE_ENABLED) == TBSTATE_ENABLED) m_wndToolBar.SetButtonStyle (1, TBBS_DISABLED); // 1 for the first two tool buttons index elsem_wndToolBar.SetButtonStyle ( 1, TBSTATE_ENABED); // 1 is the index // setting of the second tool button Press / non-pressed uint style = m_wndtoolbar.getButtonStyle (1); if (Style & TBBS_CHECKED) == TBBS_CHECKED) m_wndtoolbar.setButtonStyle (1, TBState_enabled); // 1 is the index of the second tool button else (1, tbbs_checked); // 1 is the index of the second tool button to find the definition of TBBS_DISABED, and other styles, such as TBBS_HIDDEN, TBBS_MARKED, etc.