|
-
June 18th, 1999, 11:36 AM
#1
CTreeCtrl and RButtonUp
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
-
July 29th, 2010, 05:43 PM
#2
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.
-
July 29th, 2010, 07:42 PM
#3
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!
Last edited by Eri523; January 1st, 2012 at 06:31 PM.
-
December 31st, 2011, 01:02 AM
#4
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
-
January 1st, 2012, 03:42 PM
#5
Re: CTreeCtrl and RButtonUp
To display a context menu, just handle the WM_CONTEXTMENU msg.
-
January 2nd, 2012, 05:23 AM
#6
Re: CTreeCtrl and RButtonUp
 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
-
January 2nd, 2012, 06:52 AM
#7
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|