Solved

TrackPopupMenu question

Posted on 2001-07-01
7
455 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 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.

 

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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adapt this command to show who installed 29 111
format the code in java 6 101
wait notify demo infinite loop 3 124
Unix Command -- Challenging  question 7 96
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

839 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