Solved

Receiving events from a popup menu.

Posted on 2000-03-13
10
476 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

732 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