I would like to be able to "customize" my toolbar depending on what type of child frame becomes active in my MDI application. I have been using CMFCToolbar because they look nice and Visual Studio steers you in that direction.
I could not determine how to do it automatically (like the menus change when the document type changes) so I tried creating independent toolbars for each document type - and switching them in OnMDIActivate() - but that caused too many hassles with CMFCToolbar, including:
- toolbars the wrong size
- toolbars not showing up
- reload app and the toolbar is in the wrong form (docked/undocked)even though I disabled LoadState/SaveState
- gaps where the toolbar used to be - sometimes the image is still there but the toolbar is not (no repaint of the frame)
.. so I gave up on that. [<flame>IMHO it is shockingly hard to make customized use of CMFCToolbar viz its lack of predictable behavior, ease of reading the code, documentation, etc.]
What I would like to do now is simply use *one* toolbar but gray-out certain buttons for certain document types, something like:
void CChildFrame::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd)
{
CMDIChildWndEx::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd);
if (bActivate) {
CView *theView = ((CChildFrame *)pActivateWnd)->GetActiveView();
if (theView == NULL) return;
CMainFrame *MF = (CMainFrame *)theApp.m_pMainWnd;
CMFCToolBar *TB = &MF->m_wndToolBar;
if (theView->IsKindOf ( RUNTIME_CLASS (CDrumGenView))) {
}
else if (theView->IsKindOf ( RUNTIME_CLASS (CDrumGenListingView))) {
}
else if (theView->IsKindOf ( RUNTIME_CLASS (CDrumGenStaffView))) {
}
else if (theView->IsKindOf ( RUNTIME_CLASS (CDrumGenLogView))) {
}
}
As you can see, I have a EnableButton(FALSE) call in there ... but wait, that doesn't exist any more in CMFCToolbar.
Can anyone point me to a super simple way to disable a CMFCToolbar button?
Thx