OnToolbarCreate();
然后……
void CMainFrame::OnToolbarCreate()
{
// Should only get here if we don't have a toolbar.
ASSERT(d_pToolbar2 == 0);
// Create C++ object and WinAPI window.
d_pToolbar2 = new CToolBar();
d_pToolbar2->Create(this, WS_CHILD | CBRS_BOTTOM |
CBRS_SIZE_FIXED | CBRS_FLOATING,
0x9100);
// Get bitmap and connect to tool items.
d_pToolbar2->LoadBitmap(IDR_ADD_TOOLBAR);
d_pToolbar2->SetButtons(Toolbar2Buttons,
sizeof(Toolbar2Buttons)/sizeof(UINT));
// Make toolbar dockable.
d_pToolbar2->EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(d_pToolbar2);
}
然后……
void CMainFrame::OnToolbarShow()
{
ASSERT(d_pToolbar2 != 0);
// Query current visibility.
BOOL bVisible = (d_pToolbar2->GetStyle() & WS_VISIBLE);
// Show or hide.
int nShow = (bVisible) ? SW_HIDE : SW_SHOWNORMAL;
d_pToolbar2->ShowWindow(nShow);
// Store visibility state for later.
d_bToolbarVisible = (!bVisible);
}
void CMainFrame::OnUpdateToolbarShow(CCmdUI* pCmdUI)
{
//This function is signed for checking the menu 'Edit|Show Toolbar'
pCmdUI->Enable(d_pToolbar2 != 0);
int nCheck = (d_bToolbarVisible) ? 1 : 0;
pCmdUI->SetCheck(nCheck);
}