Solved

Popup Menu

Posted on 2001-06-13
5
354 Views
Last Modified: 2010-04-06
The popup menu automatically closes when the user clicks on another component outside it.  Is there a way to know when this will occur?  Or is there a way to know when the user has clicked the mouse on any other part of the form except the pop up menu?
0
Comment
Question by:TheBreeze
5 Comments
 
LVL 9

Expert Comment

by:ITugay
ID: 6190333
listenning.....
0
 
LVL 5

Expert Comment

by:Tom Knowlton
ID: 6191316
Every event goes into the Windows Message "queue".  Capture the message and you can control the response to that event.
0
 
LVL 5

Expert Comment

by:Gwena
ID: 6192801
listening :-)
0
 

Author Comment

by:TheBreeze
ID: 6193578
KnowIton,

Pardon my ignorance, but how do I actually capture the message?
0
 
LVL 1

Accepted Solution

by:
Greyman earned 50 total points
ID: 6194063
Looking through the source code (D3) for TPopupMenu and the WIN API - I don't see any messages that can be trapped for this purpose.

However, TrackPopupMenu (the Win API function that displays a popup menu) does have a parameter that you can set that defines a rectangle where clicking does not make the popup menu go away (HTH).

To do that, instead of calling MyPopupMenu.Popup(XPos,YPos), you would need to do this:

var
  MyRect : TRect;
begin
// Set the Left, Right, Top and Bottom parts of MyRect
//to the boundaries of the rectangle where we can click
//without losing the menu

TrackPopupMenu(MyPopupMenu.Handle,TPM_LEFTALIGN or TPM_RIGHTBUTTON, XPos,YPos,0 {reserved}, Ptr(MyRect));

HTH
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

740 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