OnMouseActivate bug needs documentation |
Post Reply |
Author | |
Ark42
Senior Member Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
Posted: 10 May 2004 at 12:46pm |
In XTPDockingPane.h, the comments above AttachView really should mention that the view you attach absolutely must override the poorly documented MFC message WM_MOUSEACTIVATE and call the CWnd version, in order to bypass the CView version. If your CView does not do this, then clicking in your docked pane then floating the pane will cause you to not be able to click on any of the menu including the control box and close X button. If you close the program from the task bar, right click, and pick close, you get debug assertions relating to invalid vtables and such. Adding ON_WM_MOUSEACTIVATE() and void CYOURView::OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message) { CWnd::OnMouseActivate(pDesktopWnd, nHitTest, message); } will solve all these problems quite nicely. It took me a lot of digging through GUI_VisualStudio7 sample, which was the only sample that used AttachView for the docking panes, in order to reproduce the problem I was having. Finally when I commented out OnMouseActivate the menus broke like they always had in my program. No place in the help files or code comments mentions using OnMouseActivate, so it would have been a great help to me, and could be a great help to others in the future, to mention OnMouseActivate in XTPDockingPane.h |
|
Sven
Senior Member Joined: 21 August 2003 Location: Germany Status: Offline Points: 127 |
Post Options
Thanks(0)
|
This happens with all views which are used as normal windows, not only with docking panes. The "problem" is that CView::OnMouseActivate sets always the active view in the mainframe.
|
|
Ark42
Senior Member Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
|
Not sure what you really mean by "normal windows" since "normally" I use a CView with a CFrame and a CDocument, tied together from a CDocTemplate and there is no problem. Classwizard doesn't even list WM_MOUSEACTIVATE as a common override. This problem caused me a lot of headache and even if its not specific to codejock, it definately would not hurt anything to mention this next to AttachView()'s comments in order to help us out. |
|
Sven
Senior Member Joined: 21 August 2003 Location: Germany Status: Offline Points: 127 |
Post Options
Thanks(0)
|
I mean if you use a CView without a CDocument. In the doc/view model the mainframe has a active view and routes the menu commands to it. If you activate another view with the mouse, this view gets a WM_MOUSEACTIVATE and activates itself in the mainframe (with SetActiveView). One Example: In one of my apps I don't use the doc/view model. The mainframe dispatches the commands to the child window(s). One of the child window is a derived CFormView. If OnMouseActivate is not overridden, the derived CFormView calls SetActiveView in the mainframe and all menu commands are routed to the CFormView instead to the active child window. The derived CFormView is used as a "normal" window here. |
|
Ark42
Senior Member Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
|
I actually use CView and CFrame derived classes but CDocument itself as the parameters to CDocTemplates. I don't actually use the CDocument (its always null) but I still call it the doc/view model, and I havn't run into this problem before trying to use a CView in a docking pane. Anyway, I'm not saying its neccessarily a bug with the docking panes, but it is something that most people like myself would have to spend a lot of time researching for a fix when ussing docking panes with AttachView() so it would save us all a lot of time to put a simple comment in the header file near AttachView suggesting that the programmer override WM_MOUSEACTIVATE. |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |