Solved

Where does WM_COMMAND go?

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

Database Solutions Engineer FAQs

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller single-server environments.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

623 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