Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7637375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:55:19+00:00 2026-05-31T07:55:19+00:00

I am trying to use a context menu I created for a Dialog Box,

  • 0

I am trying to use a context menu I created for a Dialog Box, but the WM_COMMAND message which is supposed to be sent when I click a menu item is not reaching the Dialog Procedure.

I put an if statement in the message loop to check for WM_COMMAND, and it is being registered but not being sent to my Dialog Procedure.

Yes, I am using if( !IsDialogMessage( hwndListDialog, &msg ) ) to call TranslateMessage and DispatchMessage.

This is how I initialised my context menu:

listitemmenu = CreatePopupMenu();

listmenuitem1.cbSize = sizeof( menuitem1 );
listmenuitem1.fMask = MIIM_TYPE;
listmenuitem1.fType = MFT_STRING;
listmenuitem1.hSubMenu = NULL;
listmenuitem1.dwTypeData = "Copy Imgur Link";
InsertMenuItem( listitemmenu, 0, true, &listmenuitem1 ); //insert menu item

listmenuitem2.cbSize = sizeof( menuitem1 );
listmenuitem2.fMask = MIIM_TYPE;
listmenuitem2.fType = MFT_STRING;
listmenuitem2.hSubMenu = NULL;
listmenuitem2.dwTypeData = "Copy Imgur Delete Link";
InsertMenuItem( listitemmenu, 1, true, &listmenuitem2 ); //insert menu item

listmenuitem3.cbSize = sizeof( menuitem1 );
listmenuitem3.fMask = MIIM_TYPE;
listmenuitem3.fType = MFT_STRING;
listmenuitem3.hSubMenu = NULL;
listmenuitem3.dwTypeData = "Rename";
InsertMenuItem( listitemmenu, 2, true, &listmenuitem3 ); //insert menu item

listmenuitem4.cbSize = sizeof( menuitem1 );
listmenuitem4.fMask = MIIM_TYPE;
listmenuitem4.fType = MFT_STRING;
listmenuitem4.hSubMenu = NULL;
listmenuitem4.dwTypeData = "Remove from list";
InsertMenuItem( listitemmenu, 3, true, &listmenuitem4 ); //insert menu item

This is how I track the menu:

TrackPopupMenuEx( listitemmenu, TPM_LEFTBUTTON | TPM_NOANIMATION | TPM_HORIZONTAL | TPM_VERTICAL, cpos.x, cpos.y, ListControl, NULL );

This is the switch case that I am trying to use to interact with my menu:

case WM_COMMAND:
        switch( LOWORD(lParam) )
        {
        case 0:
            printf("copy link");
            break;
        case 1:
            printf("copy deletion link");
            break;
        case 2:
            printf("Rename");
            break;
        case 3:
            printf("Remove");
            break;
        }
        break;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:55:20+00:00Added an answer on May 31, 2026 at 7:55 am

    From the documentation for TrackPopupMenuEx:

    hwnd [in]

    Type: HWND

    A handle to the window that owns the shortcut menu. This window receives all messages from the menu.

    You passed ListControl as the hwnd parameter, so the WM_COMMAND is going to that window, not your dialog box. If you want the WM_COMMAND to go to your dialog box, then pass your dialog box as the hwnd.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to bind a context menu item to a command that I
I'm trying to create a right-click context menu command for compressing JavaScript files with
I'm trying to use JavaScript to find the context menu items being shown and
I'm trying to create a simple context menu item to open a file in
Trying to use this code to connect the AD PrincipalContext context = new PrincipalContext(ContextType.Domain,
Trying to use an excpetion class which could provide location reference for XML parsing,
Trying to use a guid as a resource id in a rest url but
Trying to use this method (gist of which is use self.method_name in the FunnyHelper
I'm trying to use the GMap.NET.WindowsForms control in my Windows forms application but I
I'm trying to use a datagrid in my VB application. But I'm running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.