Question regarding Message Handler for WM_OnLButtonUp

Started by
1 comment, last by Endurion 17 years, 9 months ago
I am going through creating some message handlers and having a problem understanding a certain situation. To my understanding, if a base class member function is not set to "private" this it will be available and passed down to classes drived from that base class consisting of the member function in question. However, when editing the message WM_OnLButtonUp, it will generate a call as

void CAppNameView::OnLButtonDown(UINT nFlags, CPoint point)

but it also automatically generates a call to the member function in the base class

void CView::OnLButtonDown(nFlags, point)

However, what I was hoping someone can clarify is, WHY, that has to be called if that member function should be available through my derived class of CAppNameView instead of needing a direct call to the base class member function. Obviously, I missing the boat on this, if someone can direct me back on course to understand what I am missing. Thanks,
Advertisement
I dont understand. What do you mean "generating a call to"? Are you wondering why CAppNameView::OnLButtonDown() is being called instead of CView::OnLButtonDown()? If that is the case then the reason is that by overloading OnLButtonDown() you have hidden the implementation of that function in CView. If you want to call it then you must explicitly state that you want to call the one in CView and not CAppNameView by calling it in this way:

CView::OnLButtonDown(nFlags, point)
It's on you to decide what should happen with the WM_LBUTTONDOWN message.

In the bottom most OnLButtonDown (in CWnd) it simply calls Default() which itself calls DefWindowProc with the message. It's the same behaviour as having a big switch/case where you break outside to let DefWindowProc do its default processing with the message.

If you remove the call to the base class the message will not be passed on to DefWindowProc. This may be needed for some special cases but most of the time you just do your stuff in the handler and then let Windows do the default processing.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

This topic is closed to new replies.

Advertisement