Solved

Where does WM_COMMAND go?

Posted on 2003-10-30
2
347 Views
Last Modified: 2013-11-20
I am building an ActiveX control using MFC. The control pops up a menu using CMenu::TrackPopupMenu. The menu is built dynamically by the user so the Ids are not known before hand. I am trying to intercept WM_COMMAND but it does not come at all. Even PreTranslateMessage does not get it. Using Spy++, I don't see it. I am passing (this) in the TrackPopupMenu and tried ON_MESSAGE macro and OnCommand virtual function. Where does the message go? Any hints. Thanks
0
Comment
Question by:nabehs
2 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 9648917
To handle commands from the menu you need to specify menu parent in TrackPopupMenu call. This window gets WM_COMMAND messages. Show your code to see what happens.
0
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 100 total points
ID: 9648931
Use TPM_RETURNCMD with TrackPopupMenu, so you no need to map WM_COMMAND


UINT unCMD = pSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD,
                                                       oPoint.x,
                                                       oPoint.y,
                                                       this);


will get the return in *unCMD*

Rosh :)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now