 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Mon Jun 26, 2006 4:32 pm Post subject: Delphi Dock Close Event (Guide) |
|
|
Okay, well after fighting and fighting with Delphi and docking.. And
searching the groups for any information about this (which I haven't
found, just a question).. I decided, with my pride to tackle it anyway.
I am posting this to save people headaches and giving up when they are
dealing with closing a docked control. I've tested this with a form
and a panel, I'm not sure if it'll work with other scenarios but it
should. Anyway, what you want to do, is first subclass or override the
'dock site', in this case a tpanel and listen for these two messages:
CM_UnDockClient and CM_DockNotification.
It all depends on what you have your form set to, if on the close, you
set it to caFree, it will send a CM_UnDockClient event.. If it's set to
caHide (the default behaviour), it will send a CM_DockNotification.
CM_UnDockClient:
It sends this when you undock it (by grabbing it and dragging it out),
or when you close a window when it's in there.
The LParam holds the Control, so to check if it's getting free'd we do:
IF csDestroying IN TControl (Msg.LParam).ComponentState Then
UnDockStuff;
The UnDockStuff is well, whatever you want it to do.. I use it to 'hide
the panel' again.
Warning: DO NOT CALL 'DoUnDock' OR 'ManualDock' IN HERE! It will
trigger undocking messages again and cause an infinite loop.
CM_DockNotification:
This time LParam is a pointer to a TDockNotifyRec.
We want to find out if Delphi sent us a CM_VisibleChanged (because
well, if it's set to caHide, it's just changing the visibility right?
And what happens when we change the Visible property? We get sent a
CM_VisibleChanged message!)
So we check for it:
IF PDockNotifyRec (Msg.LParam)^.ClientMsg = CM_VisibleChanged Then
UnDockStuff;
Of course once again, UnDockStuff is whatever you want.
And there you have it! That's how you find out if a form was closed
when it was docked.
(P.S. No UnDock does not get called for some reason when you close it,
you have to take advantage of these methods)
Of course it might look a bit long, but really here is the only code
you'll need in your message handler (assuming the parameter is Msg).
Case Msg.Msg OF
CM_UnDockClient :
Begin
IF csDestroying IN TControl (Msg.LParam).ComponentState Then
UnDockStuff;
End; { UnDock Client }
CM_DockNotification :
Begin
IF PDockNotifyRec (Msg.LParam)^.ClientMsg = CM_VisibleChanged
Then UnDockStuff;
End; { Dock Notification }
End; { Case }
Don't forget to give me credit if you use this information and spread
it around!
- Dennis Fehr |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Jun 27, 2006 8:14 am Post subject: Re: Delphi Dock Close Event (Guide) |
|
|
Sorry you might want to undock the control in CM_DockNotification:
CM_DockNotification:
Begin
IF PDockNotifyRec (Msg.LParam)^.ClientMsg = CM_VisibleChanged Then
Begin
TControl (Msg.WParam).ManualDock (NIL);
UnDockStuff;
End; { IF }
End; { Dock Notification } |
|
| Back to top |
|
 |
Riki Wiki Guest
|
Posted: Wed Jun 28, 2006 10:57 pm Post subject: Re: Delphi Dock Close Event (Guide) |
|
|
Hoi
You need to repost your question on the Borland news server to make
everybody see it and possibly answer your question. Further, this news
group do not officially exist, the group to use is
b.p.d.vcl.components.using.general.
How to post to Delphi newsgroups:
<http://tinyurl.com/8m5nw>
which links to
<http://delphi.wikicities.com/wiki/Delphi_Newsgroups> |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|