Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 371
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

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