How to detect Right Click 
Author Message
 How to detect Right Click

I want my window to detect a right click to throw up a popup menu. I
used the class wizard to create an OnRButtonUp function and I set the
focus to CMainFrame but even if I just throw a PostMessage(WM_CLOSE) I
get no response.

Although it wont make a difference here is my function:

void CMainFrame::OnRButtonUp(UINT nFlags, CPoint point)
{
        CMenu popup;
        popup.LoadMenu(IDR_POPUPMENU);
        CMenu* popper = popup.GetSubMenu(0);
        ClientToScreen(&point);
        popper->TrackPopupMenu(0,point.x,point.y,AfxGetMainWnd(),NULL);
        CFrameWnd::OnRButtonUp(nFlags, point);

Quote:
}

I tried it like this with no response even:

void CMainFrame::OnRButtonUp(UINT nFlags, CPoint point)
{
        PostMessage(WM_CLOSE);
        CFrameWnd::OnRButtonUp(nFlags, point);

Quote:
}

So the error is not in my coding, it just simply will not detect my
mouse buttons in the main frame (Excluding toolbars etc)

Help this novice out. . . Thanks,

        Dennis



Sun, 14 Oct 2001 03:00:00 GMT  
 How to detect Right Click
If this is a document\view app and your clicking in the view, you would want
to put the 'OnRButtonUp' command in the CView derived class and not in the
CMainFrame class.  The CMainFrame is just the 'frame' of the window.  You
might also check out 'OnContextMenu', it's called by the framework whenever
a user right clicks in the window or hits the context menu key on most
Windows keyboards.  Hope this helps...

Tom Spilman
Dalco Athletic Lettering


Quote:
>I want my window to detect a right click to throw up a popup menu. I
>used the class wizard to create an OnRButtonUp function and I set the
>focus to CMainFrame but even if I just throw a PostMessage(WM_CLOSE) I
>get no response.

>Although it wont make a difference here is my function:

>void CMainFrame::OnRButtonUp(UINT nFlags, CPoint point)
>{
> CMenu popup;
> popup.LoadMenu(IDR_POPUPMENU);
> CMenu* popper = popup.GetSubMenu(0);
> ClientToScreen(&point);
> popper->TrackPopupMenu(0,point.x,point.y,AfxGetMainWnd(),NULL);
> CFrameWnd::OnRButtonUp(nFlags, point);
>}

>I tried it like this with no response even:

>void CMainFrame::OnRButtonUp(UINT nFlags, CPoint point)
>{
> PostMessage(WM_CLOSE);
> CFrameWnd::OnRButtonUp(nFlags, point);
>}

>So the error is not in my coding, it just simply will not detect my
>mouse buttons in the main frame (Excluding toolbars etc)

>Help this novice out. . . Thanks,

> Dennis



Sun, 14 Oct 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. (Q) Detecting right click in a CListBox

2. Detect left vs. right click event

3. Detect right click on CHeaderCtrl

4. problems detecting a right-click even on a rich edit control

5. Help: Detect when right button is clicked above a button

6. Detecting right click over dialog button.

7. Handling a Right Click

8. Right Click vs. Left

9. right Click - context menu ?

10. Treeview node right-click

11. on right click ?

12. Disabling right click in WebBrowser control

 

 
Powered by phpBB® Forum Software