CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Context Menus

  1. #1
    Andrew Truckle Guest

    Context Menus



    I have a dialog based application with support for the context menu when you right-click on the dialog.


    At the moment it comes up with a cut/copy/paste menu. The problem is that this menu displays absolutely anywhere on the window, which is wrong.


    I only want it to display if it is on the IDC_CONFIG_GRID control. I assume I have to use the passed Cwnd variable in some way.


    I am desperate for someones help.


    Please email me either on this address or:

    [email protected]


    Thanks for your help!

  2. #2
    Join Date
    Mar 1999
    Posts
    8

    Re: Context Menus



    sounds like you need to adding some mouse tracking. How about:

    void CBlahDlg::OnContextMenu(CWnd* pWnd, CPoint point)

    {

    CMenu menu;

    CMenu* pSubmenu;

    menu.LoadMenu(IDR_MENU1);

    pSubmenu = menu.GetSubMenu(0);

    pSubmenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON, point.x, point.y, AfxGetApp()->m_pMainWnd,NULL);



    }



  3. #3
    Andrew Truckle Guest

    Re: Context Menus



    Hi,


    Thanks for the advice.


    I found this works:


    if(pWnd->GetDlgCtrlID() == IDC_CONFIG_GRID)

    {

    ...

    ...

    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured