Search code examples
windowstatedockingc++builder-xe

How to determine if form is docked?


How to determine in C++ Builder XE, if window is currently docked? All windows in my application are derived from base class TForm. How to catch change from docked to undocked state and vice versa?


Solution

  • The Form's HostDockSite property will be non-NULL when docked, an NULL otherwise.

    There is no specific notification for when the HostDockSite changes, but you can override the form's virtual Dock() and/or DoDock() methods to check if the HostDockSite changes when calling the inherited methods. Alternatively, override the Form's virtual SetParent() method and check for the csDocking flag in the Form's ControlState property.