Solved

Receiving events from a popup menu.

Posted on 2000-03-13
10
478 Views
Last Modified: 2013-12-03
Hi,

I have created a popup menu in my application, how do I receive events to inform the app that the user has selected an item in the menu.. I know that there are events such as WM_MENUSELECT and WM_MENUCOMMAND, but when I try to handle them, it says that WM_MENUCOMMAND etc.. is undefined...

thanks in advance

Emma
0
Comment
Question by:middlel
[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
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 2611735
are you using Trackpopupmenu? the WM_COMMAND messages should go to the window you gave as the HWnd parameter.
0
 

Author Comment

by:middlel
ID: 2611825
Yes I am using TraclPopupMenu(). I don't want to have to handle the WM_COMMAND message because I would then have to handle or forward on all the other messages that I want to handle... I would much rather be able to handle the menu specific messages...

0
 
LVL 22

Expert Comment

by:nietod
ID: 2611932
>> when I try to handle them, it says that
>> WM_MENUCOMMAND etc.. is undefined...
It IS undefined.  

WM_MENUSELECT is defined though.  What what it that you thought that WM_MENUCOMMAND was doing?

>> I don't want to have to handle the WM_COMMAND
>> message because I would then have to handle or
>> forward on all the other messages that I want to
>> handle.
I don't understand.

0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 9

Expert Comment

by:ShaunWilde
ID: 2611953
ahh I see.

WM_MENUCOMMAND is only available on 98 and NT2000 platforms (according to the MSDN)

to get the definition of it you need to set WINVER to be > 0x500 and include winuser.h

#define WINVER 0x500
#include "winuser.h"

0
 
LVL 31

Accepted Solution

by:
Zoppo earned 100 total points
ID: 2611983
Hi middlel,

You can even call TrackPopupMenu with flag TPM_RETURNCMD set, then TrackPopupMenu() doesn't return until the user selected a menu item or cancelled the menu. The return value of TrackPopupMenu() is the menu command id.

ZOPPO
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2611990
When you call the TrackPopupMenu API, if you add  TPM_RETURNCMD to the flag, it will return the menu item number selected...

See: http://msdn.microsoft.com/library/psdk/winui/menus_0hdi.htm 


Cheers!®©
0
 

Author Comment

by:middlel
ID: 2612019
Oh, Ok..  I have managed to handle WM_MENUSELECT but it is fired as soon as the mouse hovers over the menu item. I want to know which one has being selected - hence why I probably wanted to use WM_MENUCOMMAND instead..

How do I know when the user has clicked on the item.. I could probably just keep storing the menu item that the user has moved the mouse over, but how do I know if the user has clicked on or cancelled the menu.?

Emma
0
 

Author Comment

by:middlel
ID: 2612044
I have TPM_RETURNCMD set, but do I set my return type as BOOL or int..?

0
 
LVL 31

Expert Comment

by:Zoppo
ID: 2612064
You can use what you want I think coz BOOL is a typedef int ... or cast it to UINT, coz most ID's are passed as UINT...

Check: if retrurn value is zero user cancelled menu.

ZOPPO
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2612108
Use Int...


Cheers!®©
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 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