CMainFrame::OnActivate
Srikant V -- SrikantV@wintegrity.com Wednesday, October 30, 1996 Environment: VC++ 4.2b, NT4.0 My application has several MDI children and each of them have a different toolbar. To achive the switching of the tool bar as the user switches between the views, i use OnActivateView of the form view where the toolbar switching code is added But when all the views are closed i need to switch the toolbar to that of the mainframe wnd, i try adding the toolbar switching code to CMainFrame::OnActivate it does not seem to work, Is this the right place to capture the fact that all the views have been closed and it is only the mainframe wnd that is in existance. thanks sri
Hugh Robinson -- hugh@ssihou.ssii.com Thursday, October 31, 1996 [Mini-digest: 5 responses] Have you tried OnActivateFrame()? Just a guess... ---------- From: owner-mfc-l Sent: Wednesday, October 30, 1996 1:02 PM To: 'mfc-l@netcom.com' Subject: CMainFrame::OnActivate Environment: VC++ 4.2b, NT4.0 My application has several MDI children and each of them have a different toolbar. To achive the switching of the tool bar as the user switches between the views, i use OnActivateView of the form view where the toolbar switching code is added But when all the views are closed i need to switch the toolbar to that of the mainframe wnd, i try adding the toolbar switching code to CMainFrame::OnActivate it does not seem to work, Is this the right place to capture the fact that all the views have been closed and it is only the mainframe wnd that is in existance. thanks sri -----From: "Doug Brubacher"No this is not the correct spot. CMainFrame::OnActivate is sent when the application is activated or deactivate or when modal dialogs are displayed then closed. Actually you can detect this condition right in your OnActivateView. To see how this works stick the following in your OnActivateView: void CYourView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) { TRACE3( "CYourView::OnActivateView Activate %i, Active View %i, Deactive View %i\n", bActivate, pActivateView, pDeactiveView ); CView::OnActivateView(bActivate, pActivateView, pDeactiveView); } when the last view is being closed the pActiveView is NULL as you can see from these trace results. CYourView::OnActivateView Activate 0, Active View 0, Deactive View 4269344 Regards, Doug Brubacher DouglasB@msn.com -----From: "Jeff S. Shanholtz" Looks like what you need to do since you've got an mdi app is use the OnMDIActivate member function of the CMDIChildWnd class. In case you're not familiar with OnMDIActivate, it gets called for both the window being deactivated and the window being activated, so when it gets called for a deactivating window, you can check to see if that is the last window and that it is being closed. If so, you can switch your toolbar to the mainframe one. Jeff Shanholtz Enertech Consultants -----From: "Dan Kirby" You can do something like what MFC does for menus and handle the switching of the toolbars in the OnMDIActivate handler. See the code for CMDIChildwnd::OnMDIActivate() to get an idea of how menus are switched. --dan -----From: Dong Chen There might be a better way to do it. But you can use this old fashion method: posting a user defined message. Add a pointer for each of your views as public member variables in your mainframe class. When you close a view, set the pointer for this view to NULL and post the message. You can get the view's pointer by doing something like AfxGetApp()->m_m_pMainWnd->m_pViewA. In the message handler in mainframe, check to see if all pointers are NULLs. If so, display the mainframe toolbar. Make sure you initialize the pointers as NULL if you start the mainframe without any views, which can be done in your apps InitInstance function after you have your mainframe window set. -- Dong
| Вернуться в корень Архива |