Solved

Where does WM_COMMAND go?

Posted on 2003-10-30
2
380 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

820 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