Jump to content
  • Advertisement
Sign in to follow this  
pghTech

Question regarding Message Handler for WM_OnLButtonUp

This topic is 4338 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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,

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!