Click to See Complete Forum and Search --> : CTreeCtrl and RButtonUp
WDW
June 18th, 1999, 11:36 AM
In my TreeView control...
I used ClassWizard to connect the WM_RBUTTONUP to the Member function OnRButtonUp. The problem with this is that it only occurs when I double right click OR when I move the cursor while the right mouse button is down. I want to add a popup menu where I right-clicked and get the hItem that was clicked.
Any help would be appreciated,
WDW
sgeppert
July 29th, 2010, 05:43 PM
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.
Eri523
July 29th, 2010, 07:42 PM
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! :)
Randor
December 31st, 2011, 12:02 AM
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
Arjay
January 1st, 2012, 02:42 PM
To display a context menu, just handle the WM_CONTEXTMENU msg.
Randor
January 2nd, 2012, 04:23 AM
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
Arjay
January 2nd, 2012, 05:52 AM
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.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.