?
Solved

Receiving events from a popup menu.

Posted on 2000-03-13
10
Medium Priority
?
481 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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 400 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

762 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