OnActivateView bug??
Jeff Wishnie -- jwishnie@swellsoft.com Monday, May 20, 1996 Config: Win95 VisC++/MFC 4.1 App Details: Vanilla MDI app In my CView subclass, I need to know whether OnActivateView is being called because the entire application is being activated/deactivated (e.g. when the user switches applications) or because the user has switched from another view in the _same_ app (e.g. clicked in the other pane in a splitter or activated a new MDI child window). Here's what OnActivateView looks like:=20 virtual void OnActivateView( BOOL bActivate, CView* pActivateView, CView* pDeactiveView ); And according to the MFC docs, if the view is being activated/deactivated within the app pActivateView and pDeactivateView will be different. If the method is being called because the app is being activated/deactivated, the arguments should be equal. >From the docs: "The pActivateView and pDeactiveView parameters point to the same view if the application's main frame window is activated with no change in the active view=97for example, if the focus is being transferred from another application to this one, rather than from one view to another within the application or when switching amongst MDI child windows." Here's the problem: the two arguments are _ALWAYS_ equal, no matter what caused the activate event. I created a completely generic AppWizard generated MDI app to test this. Here is my views OnActivateView method: void CActivateTestView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)=20 { TRACE("Activate View: %x DeactiveView: %x\n", pActivateView,= pDeactiveView); CView::OnActivateView(bActivate, pActivateView, pDeactiveView); } The output shows the two pointers are always equal. Question: Is this a known bug? (I couldn't find any mention in KB) Is there a workaround? Is it just a documentation bug, and the values _are_ supposed to be equal when switching among MDI child windows??? Thanks for any help, Jeff =20 jwishnie@swellsoft.com 415 552-3125(w)
Frederic Steppe -- FredericS@msn.com Thursday, May 23, 1996 >Config: Win95 VisC++/MFC 4.1 >App Details: Vanilla MDI app >In my CView subclass, I need to know whether OnActivateView is being called >because the entire application is being activated/deactivated (e.g. when the >user switches applications) or because the user has switched from another >view in the _same_ app (e.g. clicked in the other pane in a splitter or >activated a new MDI child window). >And according to the MFC docs, if the view is being activated/deactivated >within the app pActivateView and pDeactivateView will be different. >If the method is being called because the app is being >activated/deactivated, the arguments should be equal. >Here's the problem: the two arguments are _ALWAYS_ equal, no matter what >caused the activate event. The same doc article also says : These parameters differ when CFrameWnd::SetActiveView is called with a view that is different from what CFrameWnd::GetActiveView would return. That means that is when two views are switched inside one frame (splitters). I guess it can be a documentation mistake, as the two explainations seems to be contradictory. You should try to trap OnActivateApp to deal with this. Frederic Steppe (frederics@msn.com)
| Вернуться в корень Архива |