Solved

Popup Menu

Posted on 2001-06-13
5
350 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: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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video discusses moving either the default database or any database to a new volume.
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: …

743 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

13 Experts available now in Live!

Get 1:1 Help Now