1

Let's consider this code fragment :

BEGIN_MESSAGE_MAP(CMyCheckBox, CButton)
  ON_WM_MOUSEMOVE()
END_MESSAGE_MAP()

void CMyCheckBox::OnMouseMove(UINT nFlags, CPoint point)
{
    // here my code ....

   CButton::OnMouseMove(nFlags, point); // <-- Is this important ?
}

Questions :

1- Is the base class call mandatory?

 CButton::OnMouseMove(nFlags, point);  // <-- Is this mandatory?

2- If I don't add it, what's going to happen? ( window message stack overflow for example ) ?
3- Is the base class call a form of message release? If so, is there another way to release the message properly?

Landstalker
  • 1,368
  • 8
  • 9

1 Answers1

1

Window messages and their associated data are managed by the system. It generates the messages and associated data, hands both of these to your program, and cleans up when the message handler(s) return control back to the system.

This is unrelated to MFC's implementation using C++ class hierarchies. A base class call is mandatory, if the base class needs to observe the message. This is trivial to answer, if you authored the base class. If the base class is provided by MFC, the documentation points out, whether a call to the base class implementation is mandatory for proper functioning (e.g. CWnd::OnCommand).

IInspectable
  • 46,945
  • 8
  • 85
  • 181