Mega Search
23.2 Million


Sign Up

Make a donation  
How detect and cancel active popup menu  
News Group: embarcadero.public.delphi.nativeapi

Hi,

My app can asynchronously switch state. When this happens I need to close any popup menu that's active (may be in the main window, may be in a child window). This leads to 2 questions:
-1- how can I find if there's a popup menu active (and get a handle to it)
-2- how can I cancel this popup menu?

Thanks in advance,

Gerrit Beuze

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 17-Sep-2014, at 12:08 AM EST
From: Gerrit Beuze
 
Re: How detect and cancel active popup menu  
News Group: embarcadero.public.delphi.nativeapi
> Call the Win32 API EndMenu() function, or send a WM_CANCELMODE message to 
> the menu's owner window.  If you are using a VCL menu, the owner window is 
> specified in the Window property of the global "PopupList" object of the 
> Vcl.Menus unit.

Thanks, it works indeed for VCL based popups, Unfortunately I'm using TB2/TBX based menus and that does not work.
Just incase anyone else is interested: what does work is
H := GetCapture();
if (H <> 0) then
  SendMessage(H, WM_CANCELMODE, 0, 0);

This will cancel all controls (in this app) that had the capture, but in my case that is OK,

Gerrit Beuze

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 19-Sep-2014, at 12:26 AM EST
From: Gerrit Beuze
 
Re: How detect and cancel active popup menu  
News Group: embarcadero.public.delphi.nativeapi
Gerrit wrote:

> -1- how can I find if there's a popup menu active (and get a
> handle to it)

You don't, nor do you need it.

> -2- how can I cancel this popup menu?

Call the Win32 API EndMenu() function, or send a WM_CANCELMODE message to 
the menu's owner window.  If you are using a VCL menu, the owner window is 
specified in the Window property of the global "PopupList" object of the 
Vcl.Menus unit.

--
Remy Lebeau (TeamB)

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 17-Sep-2014, at 9:36 AM EST
From: Remy Lebeau (TeamB)