Solved

Where does WM_COMMAND go?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Question regarding Copy/Paste 16 91
Tab names are off by one 5 53
wait notify demo infinite loop 3 96
child constructor and parent constructor, overriding and overloading 6 79
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 …
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…
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 tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

896 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

14 Experts available now in Live!

Get 1:1 Help Now