trap Windows Messages in a Component

  • 主题发起人 主题发起人 import
  • 开始时间 开始时间
I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
...trap Windows Messages in a Component?  
{
TApplication includes a method called HookMainWindow that allows you to
insert your own message handler at the top of WndProc to intercept messages sent
to your application before they're handled by the Application object.
HookMainWindow() is declared under TApplication as follows:
}
procedure HookMainWindow(Hook : TWindowHook);
{
HookMainWindow() takes one parameter (Hook of type TWindowHook).
TWindowHook is a method pointer type that's defined like so:
}
type
TWindowHook = function(var Message : TMessage) : Boolean of object;
{
Since TWindowHook is a method pointer, you can define your own method as
the hook function as long as it follows the nomenclature defined for TWindowHook.
The return value of the function is of type Boolean.
This is the equivalent of the "Handled" parameter of OnMessage.
If your function handles a particular message, you'd return true.
This will be passed back to the Application's WndProc and message processing for that
message will be terminated. Otherwise, you'd return False.
The Component "MessageReceiver" intercepts user-definded messages
(> WM_USER) und as example the message WM_TIMECHANGE.
}
{*************************************************************************}
{
TApplication besitzt eine Methode HookMainWindow.
Damit kann man in die Windows Prozedur (WndProc) "einhaken" und Nachrichten,
welche an die Applikation geschickt werden, abfangen und behandeln.
HookMainWindow is wie folgt deklariert:
}
procedure HookMainWindow(Hook : TWindowHook);
{ Und der Parameter TWindowHook (Methoden Pointer) so: }
type
TWindowHook = function(var Message : TMessage) : Boolean of object;
{
Der R
 
后退
顶部