Search code examples
c++wxwidgets

Handle EVT_MOTION in wxMDIParentFrame


Main parent frame class myMainFrame which is derived from wxMDIParentFrame class seems to be not handling mouse events. Issue can be easily reproduced with a sample MDI application.

BEGIN_EVENT_TABLE(myMainFrame,wxMDIParentFrame)
EVT_MOTION(myMainFrame::OnMouseMove)
END_EVENT_TABLE()

void myMainFrame::OnMouseMove(wxMouseEvent& event)
{
//...
}

I called

Connect(0, wxEVT_MOTION, (wxObjectEventFunction) (wxEventFunction) (wxMouseEventFunction) OnMouseMove);

from myMainFrame constructor, but that didn't fix the issue.

Please suggest.


Solution

  • You will have trouble receiving mouse events from the parent MDI frame because it's entirely covered by other windows. In wxGTK, it's basically a wxNotebook, with child frames being its pages. In wxMSW, it's a real frame, but it contains what Windows calls "client window", that in turn contains MDI children, so it's this window, not exposed by wxWidgets, that gets all the events.

    In short, this is not supported and very unlikely to ever be.