Re: CTreeCtrl and RButtonUp
This appears to happen when you only implement a message handler for WM_RBUTTONUP. Try processing both WM_RBUTTONDOWN and WM_RBUTTONUP and your method will be invoked when the user single clicks with the right mouse button on a tree item.
Re: CTreeCtrl and RButtonUp
Good intent, but the post you are replying to is a little more than 11 years old, and the guy who wrote it didn't ever post again since then. I'm pretty sure he won't read that.
You should better answer a more recent question next time. ;)
But anyway, welcome to CodeGuru! :)
Re: CTreeCtrl and RButtonUp
Heh,
I apologize for once again resurrecting an old thread. This page actually comes up with a high search engine ranking when you search for CTreeCtrl not recieving the WM_RBUTTONUP message.
Since the information here is incorrect lets fix that so the next guy gets good information.
The CTreeCtrl has what I could consider a design flaw in that it internally processes the WM_RBUTTONDOWN and WM_RBUTTONUP messages. If your wondering where your WM_RBUTTONUP went... it was consumed by the CTreeCtrl class... and in its place... a WM_NOTIFY containing a NM_RCLICK was sent to the parent window followed by a WM_CONTEXTMENU message to the parent window.
So... if you want to handle WM_RBUTTONUP in a CTreeCtrl derived class... you will need to add a ON_NOTIFY_REFLECT handler for the NM_RCLICK message and then sendmessage the WM_CONTEXTMENU to your own window handle.
Best Wishes,
-David Delaune
Re: CTreeCtrl and RButtonUp
To display a context menu, just handle the WM_CONTEXTMENU msg.
Re: CTreeCtrl and RButtonUp
Quote:
Originally Posted by
Arjay
To display a context menu, just handle the WM_CONTEXTMENU msg.
Hi Arjay,
Unfortunately a CTreeCtrl derived class will never recieve a WM_CONTEXTMENU message in response to a right click. If you want to display a context menu when the user right clicks in your CTreeCtrl derived class you will need to add a ON_NOTIFY_REFLECT handler for the NM_RCLICK message and then sendmessage the WM_CONTEXTMENU manually.
Best Wishes,
-David Delaune
Re: CTreeCtrl and RButtonUp
If the tree control is a derived class, yes you must reflect and use on notify (like when deriving all control clases); otherwise just handle the wm_contextmeu msg.
The main point is to handle WM_CONTEXTMENU over the right button up/down messages.