RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TApplication.HookMainWindow Method

Enables a native Windows dialog box to receive messages sent to the application's main window.

Pascal
procedure HookMainWindow(Hook: TWindowHook);
C++
__fastcall HookMainWindow(TWindowHook Hook);

Use HookMainWindow to ensure that a native Windows dialog box behaves correctly as a child of the application, not as a stand-alone window. For example, switching among applications with Alt+Tab treats the application as a single task after calling HookMainWindow, rather than treating the native Windows dialog box as a separate task. 

When the window identified by the Handle property receives relevant dialog messages, it passes them to the dialog procedure passed as the Hook parameter.  

There is no problem with leaving a dialog box hooked into the main window, even for extended periods. However, should the dialog box close, call the UnhookMainWindow method to release the hook. 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!