Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 509
  • Last Modified:

Receiving events from a popup menu.

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
middlel
Asked:
middlel
  • 3
  • 2
  • 2
  • +2
1 Solution
 
ShaunWildeCommented:
are you using Trackpopupmenu? the WM_COMMAND messages should go to the window you gave as the HWnd parameter.
0
 
middlelAuthor Commented:
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
 
nietodCommented:
>> 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 
ShaunWildeCommented:
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
 
ZoppoCommented:
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
 
mcriderCommented:
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
 
middlelAuthor Commented:
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
 
middlelAuthor Commented:
I have TPM_RETURNCMD set, but do I set my return type as BOOL or int..?

0
 
ZoppoCommented:
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
 
mcriderCommented:
Use Int...


Cheers!®©
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now