Solved

TrackPopupMenu question

Posted on 2001-07-01
7
416 Views
Last Modified: 2013-11-20
Hi,
how can I know when a popup menu created by "TrackPopupMenu" is closed ???

thanks,
Yoav.

0
Comment
Question by:yoavo
7 Comments
 
LVL 7

Expert Comment

by:peterchen092700
ID: 6243670
You can use teh TMP_RETURNCMD flag, so TrackPopupMenu will not return before user selected a command (or calcened the menu). The return value is the command id of the selected item, or 0 if the user did cancel.

Helped?
Peter
0
 
LVL 2

Expert Comment

by:MaheshSundararaman
ID: 6243754
Dear yoavo

According to TrackPopupMenu syntax

BOOL TrackPopupMenu( UINT nFlags, int x, int y, CWnd* pWnd, LPCRECT lpRect = NULL );

Return Value

Nonzero if the function is successful; otherwise 0.

So capture the return value and chaeck if greater than zero..successful completion means it has executed successfully


0
 
LVL 42

Expert Comment

by:sedgwick
ID: 6243793
yoavo: use TMP_RETURNCMD flag according to peterchen, and use switch() to determine user's selection:

int nRes = menu->TrackPopupMenu(TPM_CENTERALIGN|TPM_RETURNCMD , point.x, point.y, this);

switch(nRes)
{
case 0: //no sub menu item was selected
.
.
.
}

good luck
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:yoavo
ID: 6244170
TrackPopupMenu returns immediately even with the TPM_RETURNCMD. with out waiting the popup menu selection.
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 25 total points
ID: 6244196
thats not true my man, TrackPopUpMenu doesn't return a value until the menu is closed either by selection of the user or by clicking on other window which causes termination of the menu
0
 
LVL 2

Expert Comment

by:MaheshSundararaman
ID: 6244343
i agree with sedgwick
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6246899
yoavo,
you may be experiencing a problem that can be seen when working with so-called "tray icons"  It is related to the tray-icon's window not being the foreground application.  There is a simple solution if this is your problem.

  GetCursorPos(&pt);
  ::SetForegroundWindow( m_rNID.hWnd );  // bug Q135788
  pSubMenu->TrackPopupMenu(0, pt.x,pt.y, this, NULL);

-- Dan
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
repeatEnd java challenge 42 83
Macro to save highlighted rows as a separate file 5 38
isEverywhere  challenge 19 64
Change to event 1 73
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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 …
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 video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

705 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

16 Experts available now in Live!

Get 1:1 Help Now