component TacFormHookComponent class
Hierarchy See also
Return to Introduction 
Unit
acClasses  

Declaration
type  
  TacFormHookComponent = class(TacComponent)  
  protected  
    procedure MessageBefore(var Message: TMessage; var Handled: Boolean); virtual;  
    procedure MessageAfter(var Message: TMessage); virtual;  
    procedure FormRecreate; virtual;  
 
    function  GetParentHandle: THandle; virtual;  
    function  GetSystemMenuHandle: hMenu; virtual;  
  public  
    constructor Create(aOwner: TComponent); override;  
    destructor Destroy; override;  
 
    procedure RefreshNCArea;  // refreshes all non-client area of form  
    procedure ShowParentForm; // brings form to front and restores it if it was minimized  
 
    property Parent: TWinControl;  
    property ParentForm: TForm; // nil if parent is not form  
    property ParentHandle: THandle;   // read-only  
    property SystemMenuHandle: hMenu; // read-only  
    property OldWndProc: Pointer;     // read-only  
    property WindowStyle: LongInt;  
    property WindowExStyle: LongInt;  
 
    property Topmost: Boolean;  
    property TopmostDesign: Boolean;  // read-only  
  end;  

Description
The TacFormHookComponent class hooks all Windows messages (WM_xxx) that passes to the Delphi/BCB forms and let you process these messages by hooking MessageBefore and MessageAfter protected routines. By hooking the FormRecreate procedure — you can be notified after recreationg of the form's window handle.  



Protected Methods
MessageBeforeHooks all windows messages, before they will passed to default message handler. If you have processed this message and do not want to pass it to default message handler, set Handled parameter True. See also OnMessageBefore event of TacFormHook component.  
 
MessageAfter Hooks windows message after their processed by default message handler. See also OnMessageAfter event of TacFormHook component.  
 
FormRecreateThe FormRecreate routine hooks the recreation of form's window handle (for example, after changing of the BorderStyle or FormStyle property values). Modify the FormRecreate handler to restore necessary form styles and hooks after recreation of your form. See also OnFormRecreate event of TacFormHook component.  
 
GetParentHandleFunction returns the window handle of the owner form (or owner control). Usually it returns window handle of owner control, however, if the owner is a form with FormStyle = fsMDIForm, it returns client handle (handle of client area).  
GetSysemMenuHandleReturns handle of the system menu of the owner form, or NULL if the owner is not a form.  

Public methods
RefreshNCAreaMethod repaints all non-client parts of window (i.e: frames, caption buttons etc).  

Public properties
ParentReturns and changes the pointer to the owner form or owner control. At once after changing the parent, component will hook messages of another, specified control. Please change this property with caution, because some successors of TacFormHookComponent could not work without form;  
ParentFormReturns and changes the pointer to the owner form. Returns NULL if the owner is not a form;  
ParentHandleRead-only property. Returns same value as GetParentHandle routine in "protected" section. Note that Parent of TacFormHookComponent must be always TWinControl or its successor (see TacComponent);  
SystemMenuHandleRead-only. Returns same as GetSystemMenuHandle routine in "protected" section;  
OldWndProcPointer to the previous, hooked message handler;  
WindowStyleDetermines and / or changes a window style (same as GetWindowLong(Handle, GWL_STYLE));  
WindowExStyleDetermines and / or changes an extended window style (same as GetWindowLong(Handle, GWL_EXSTYLE)).  
TopmostReturns True if owner form is "stays on top". This property is published in the acFormTopmost, acFormHook, acFormMagnet and acAppBar components.  
TopmostDesignDetermines the pre-designed value of Topmost property (used internally).  



See also
TacComponent, TacHFormHookComponent, TacAppHookComponent classes and acFormHook component.