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

Thread: Add a right click pop up menu

  1. #1
    Join Date
    Jul 2006
    Posts
    141

    Add a right click pop up menu

    Hello

    Is there any way to add a pop up menu on right click in a dialog application?

    Thank you

  2. #2
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Add a right click pop up menu

    Checkout the CMenu object and google for some examples on how to use it.

  3. #3
    Join Date
    Apr 2009
    Posts
    598

    Re: Add a right click pop up menu

    If you are not using MFC, you can write something like the following code, which is creates a popup menu containing one entry:
    Code:
    /* ========================================================== */
    int open_popupmenu_w(HWND hwnd, int x_mouse, int y_mouse)
    {
       HMENU hMenu;
       char s[250]; RECT rc;
    
       hMenu = CreatePopupMenu();
    
       GetWindowRect(hwnd, &rc);
    
       sprintf(s, "name of option");
       AppendMenu(hMenu, MF_STRING | MF_ENABLED, (UINT) (5002), s);
    
       TrackPopupMenu(
          hMenu, // handle of pop-up menu
          TPM_LEFTALIGN | TPM_LEFTBUTTON, // screen-position and mouse-button flags
          x_mouse + 10 + rc.left,	// horizontal position, in screen coordinates
          y_mouse + 20 + rc.top,	// vertical position, in screen coordinates
          (int) (0), // reserved, must be zero
          hwnd,	// handle of owner window
          NULL // points to RECT that specifies no-dismissal area
       );
    
       return TRUE;
    }

  4. #4
    Join Date
    Feb 2005
    Posts
    2,160

    Re: Add a right click pop up menu

    If you ARE using MFC, look at the CWnd::OnContextMenu event handler.

  5. #5
    Join Date
    Jul 2006
    Posts
    141

    Re: Add a right click pop up menu

    Thanks a lot

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)