Re: hiding a panel when the user clicks everywhere on the form
From: Kurt Barthelmess (kbarthelmess_at_compuserve.com)
Date: 12/18/03
- Next message: Muzzy: "Retreive Hardware Info: Processor ID, HD ID, etc?"
- Previous message: Rob Kennedy: "Re: Creating a task bar like window..."
- In reply to: "Tobias": "Re: hiding a panel when the user clicks everywhere on the form"
- Next in thread: "Tobias": "Re: hiding a panel when the user clicks everywhere on the form"
- Reply: "Tobias": "Re: hiding a panel when the user clicks everywhere on the form"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 18 Dec 2003 16:50:40 GMT
"Tobias" . wrote:
>i thought that it could be done by calling some api functions
>such as SetCapture/ReleaseCapture. but please remember that i
>want to hide the panel only if the user clicks on the form not
>desktop.
I considered suggesting that but decided not to for a couple of
reasons. When you capture the mouse, it means you get all mouse
messages. So if the user moves out of your form and clicks on another
application, that application won't get the message and become
activated. You could try to pass the message on, but what happens if
the user tries to click on a button in another application - that
button needs not only to see the click, but capture the mouse itself.
You can also have the mouse taken away from you without notice. So I
decided not to open that can of worms<g>.
>will handling mouse down event in Application.OnMessage cause
>all the same events to be sent to this handler?
Application.OnMessage gets called for every message retrieved from the
queue. So it is important not to put a lot of code in there. Just put
a quick check like so:
{ Don't do anything if I have shown the panel }
if not PanelVisibleFlag then Exit;
{ Don't do anything if it's not a button up message }
if Msg.message <> WM_LBUTTONUP then Exit;
{ Check to see where the button up happened - if }
{ outside my window, exit }
HideThePanel;
PanelVisibleFlag := False;
>should i place
>all codes that are located in the related OnMouseDown events
>there? in that case, it will become a nightmare:-)
No. This code handles only the mouse up notification, and only when
you have shown the panel. All the mouse down processing is done in the
respective event handlers, particularly the TLabel, where you show the
panel and set PanelVisibleFlag to true.
Good luck.
Kurt
- Next message: Muzzy: "Retreive Hardware Info: Processor ID, HD ID, etc?"
- Previous message: Rob Kennedy: "Re: Creating a task bar like window..."
- In reply to: "Tobias": "Re: hiding a panel when the user clicks everywhere on the form"
- Next in thread: "Tobias": "Re: hiding a panel when the user clicks everywhere on the form"
- Reply: "Tobias": "Re: hiding a panel when the user clicks everywhere on the form"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]