CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2007
    Location
    France
    Posts
    329

    Detect context menu item was clicked in listview

    Code:
                HMENU hPopupMenu = CreatePopupMenu();
                InsertMenu(hPopupMenu, 
                           0,
                           MF_BYPOSITION | MF_STRING,
                           (UINT_PTR)hPopupMenu,
                           GlobalBuf2);
                TrackPopupMenu(hPopupMenu,
                  TPM_BOTTOMALIGN | TPM_LEFTALIGN | TPM_LEFTBUTTON,
                           p.x,
                           p.y,
                           0, //Reserved; must be zero.
                           hDlg, 
                           NULL); //Ignored.
    I know that hDlg receives all messages from the menu.
    But what kind of messages it gets?

    I put a WM_LBUTTONDOWN case in WM_COMMAND but nothing happens when i click on the context menu.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Detect context menu item was clicked in listview

    Your hDlg receives WM_COMMAND message with the WPARAM set to Menu identifier (menu item ID).
    See http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx
    Victor Nijegorodov

  3. #3
    Join Date
    Dec 2007
    Location
    France
    Posts
    329

    Re: Detect context menu item was clicked in listview

    Yes thank you Victor i found it. Its always easier after a good night sleep.
    I had to create an identifier and set it as InsertMenu's four parameter.
    And then check this identifier in WM_COMMAND.

    Have a nice sunday!

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