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

  • Home
  • SEARCH
  • 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 8614813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:12:44+00:00 2026-06-12T05:12:44+00:00

The code below creates a window, implements a CListViewCtrl and tries to make a

  • 0

The code below creates a window, implements a CListViewCtrl and tries to make a context menu with 3 options: new, edit & delete.

class CGuiView : public CWindowImpl<CGuiView, CListViewCtrl>
{
    HMENU hPopupMenu;
    MENUINFO m_ContextMenuInfo;

public:
    DECLARE_WND_CLASS(NULL)

    BOOL PreTranslateMessage(MSG* pMsg)
    {
        pMsg;
        return FALSE;
    }

    BEGIN_MSG_MAP(CGuiView)
        MESSAGE_HANDLER(WM_PAINT, OnPaint)
    //  MESSAGE_HANDLER(WM_LBUTTONUP,)
         MSG_WM_CONTEXTMENU(OnContextMenu) 
         COMMAND_ID_HANDLER(ID_CTXMENU_NEW, OnNewTask)
    END_MSG_MAP()


    LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    {
        CPaintDC dc(m_hWnd);

        //TODO: Add your drawing code here

        return 0;
    }
     void OnContextMenu ( HWND hwndCtrl, CPoint ptClick )
    {


        hPopupMenu = CreatePopupMenu();

        InsertMenu(hPopupMenu,  0, MF_BYCOMMAND | MF_STRING, ID_CTXMENU_DELETE, TEXT("Delete"));
        InsertMenu(hPopupMenu, ID_CTXMENU_DELETE, MF_BYCOMMAND | MF_STRING, ID_CTXMENU_EDIT, TEXT("Edit"));
        InsertMenu(hPopupMenu, ID_CTXMENU_EDIT, MF_BYCOMMAND | MF_STRING | MF_ENABLED, ID_CTXMENU_NEW , TEXT("New"));

        TrackPopupMenu(hPopupMenu, TPM_TOPALIGN | TPM_LEFTALIGN, ptClick.x, ptClick.y, 0,GetParent(), NULL); 


    }

    LRESULT OnNewTask(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    {

        CAboutDlg dlg;
        dlg.DoModal();
        return 0;
    }

};

The problem is that the code above does not enter OnNewTask when I click on the New menu item that I create in the OnContextMenu function. What I am doing wrong?

  • 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-06-12T05:12:45+00:00Added an answer on June 12, 2026 at 5:12 am

    You are providing GetParent() as an argument to the TrackPopupMenu API function. So WM_COMMAND is sent to the list view parent, not list view itself.

    Have it sent to the list view, or forward commands from parent to list view. You can also use Spy++ tool to check the messages in the debugged process to see what exactly is sent and where.

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

Sidebar

Related Questions

I am having trouble with some javascript. The code snippet below creates a simple
I have a working JavaScript code below which dynamically creates JSON object using JSON.parse
In the below code, i am trying to reference an external .dll, which creates
The code below creates a column of three labels. I would like to take
Okay, so I've got the following code shown below to create a dialog using
the code below gives compilation error when I try to create test t[2]; because
I am using below code to create a reminder in Google calendar (using Google
I use the below code to create and read my database in the app
I created a DatePicker user control (ASP code below, no code behind) which is
Given the code below, how would you create/implement SR.h so that it produces the

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.