Problems with OnContextMenu in my CTreeCtrl derrived class 
Author Message
 Problems with OnContextMenu in my CTreeCtrl derrived class

Hi,

I have the following problem with my CTreeCtrl derrived class (which i have
put in a control bar inside the main frame of a standard MDI application):
OnContextMenu is only called by the frame work when i double click with the
right mouse button!!?!!
In the documentation i found out that WM_CONTEXTMENU is sent when
WM_RBUTTONUP is recieved. I also found the TreeView notification NM_RCLICK.
Soo I added handlers for these in my class, and found that I get the
NM_RCLICK only on the first right click, and if i click the right mouse
button immediatly after i get a WM_RBUTTONUP and a WM_CONTEXTMENU - Strange!

Soo can anyone point me in the right direction here, or maybe tell me if i
can get the mouse coordinates somehow when i get the NM_RCLICK message so
that i can pass it on to WM_CONTEXTMENU?

please help,

regards,

/Jens B



Mon, 06 Aug 2001 03:00:00 GMT  
 Problems with OnContextMenu in my CTreeCtrl derrived class

Quote:
>I have the following problem with my CTreeCtrl derrived class (which i have
>put in a control bar inside the main frame of a standard MDI application):
>OnContextMenu is only called by the frame work when i double click with the
>right mouse button!!?!!

Jens,

I found this tip on the codeguru site:

void CLeftView::OnRButtonDown(UINT nFlags, CPoint point)
{
#pragma message("Removing this default handler lets the context menu
work!")    
//      CTreeView::OnRButtonDown(nFlags, point);

Quote:
}

Preventing the default handling of WM_RBUTTONDOWN it allows the tree
control to handle its own WM_CONTEXTMENU message. Without this the
message only goes to the tree control's parent window (unless you
double click).

I'd be interested to know a more detailed explanation of why this
quirk exists - if anyone knows?

Dave
----
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Mon, 06 Aug 2001 03:00:00 GMT  
 Problems with OnContextMenu in my CTreeCtrl derrived class

Quote:
>I'd be interested to know a more detailed explanation of why this
>quirk exists - if anyone knows?

When you click the mouse button (either), the tree ctrl doesn't know whether
you intend a drag/drop operation, or expect the context menu.  If the mouse
is moved, then the TVN_BEGIN(R)DRAG notification is sent.  When the mouse is
released NM_(R)CLICK is sent - but only if the mouse hadn't moved (if the
mouse has moved, then I think that's when you get a WM_CONTEXTMENU msg).

The easiest method is not to bother handling WM_CONTEXTMENU at all, but put
your popup menu code in the NM_RCLICK notification (and use ::GetCursorPos
for the mouse pos).

Stopping OnRButtonDown getting to the control, stops its default message
handling, i.e. creating the TVN_BEGINDRAG/NM_CLICK notifications.



Mon, 06 Aug 2001 03:00:00 GMT  
 Problems with OnContextMenu in my CTreeCtrl derrived class

Quote:
>When you click the mouse button (either), the tree ctrl doesn't know whether
>you intend a drag/drop operation, or expect the context menu.  If the mouse
>is moved, then the TVN_BEGIN(R)DRAG notification is sent.  When the mouse is
>released NM_(R)CLICK is sent - but only if the mouse hadn't moved (if the
>mouse has moved, then I think that's when you get a WM_CONTEXTMENU msg).

I had wondered if the drag/drop facility may be the cause and I also
tried using the TVS_DISABLEDRAGDROP style to see if that circumvented
the quirk, but it didn't.

I'll try your suggestion as I need to use the drag & drop operation
eventually.

Dave
----
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Tue, 07 Aug 2001 03:00:00 GMT  
 Problems with OnContextMenu in my CTreeCtrl derrived class
Richard,

Quote:
> but put
>your popup menu code in the NM_RCLICK notification (and use ::GetCursorPos
> for the mouse pos).

I wonder if you could point me to any example code for this.
Thanks.

Martin Koeck
---
spam prevention: please reply to forum only



Sun, 12 Aug 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Problems with OnContextMenu in my CTreeCtrl derrived class

2. Problems with OnContextMenu in my CTreeCtrl derrived class

3. Derrive a C# class from C++ class ?

4. CTreeCtrl:: selecting onContextMenu ?????

5. Derrive classes - newbie...

6. HELP CTreeCtrl : OnGetdispinfo doesn't work in CTreeCtrl derived class

7. CTreeCtrl derived class problem

8. SDI/Splitter/Multiple Static View OnContextMenu Problem

9. Problem with OnContextMenu

10. OnContextMenu and window Focus problem

11. Problem using OnContextMenu

12. Problem displaying Popup menu in TreeView using OnContextMenu

 

 
Powered by phpBB® Forum Software