• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 370
  • Last Modified:

Popup Menu

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
TheBreeze
Asked:
TheBreeze
1 Solution
 
ITugayCommented:
listenning.....
0
 
Tom KnowltonWeb developerCommented:
Every event goes into the Windows Message "queue".  Capture the message and you can control the response to that event.
0
 
GwenaCommented:
listening :-)
0
 
TheBreezeAuthor Commented:
KnowIton,

Pardon my ignorance, but how do I actually capture the message?
0
 
GreymanCommented:
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

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now