Solved

Where does WM_COMMAND go?

Posted on 2003-10-30
2
388 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
List out all word 7 354
Best tools for Backup and restore of Wordpress site 6 58
has22 challenge 11 109
Trying to run powershell  in a batch file. How do I do this? 8 123
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

734 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