Solved

TrackPopupMenu question

Posted on 2001-07-01
7
429 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 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

14 Experts available now in Live!

Get 1:1 Help Now