Unit ucallhwnd;interfaceuses Classes, Messages, windows;const wm_user_msg = wm_user + 1;type Tcallhwnd = Class (TObject) private fhwnd:thandle; Protected Procedure Dousermessage (var amsg:tmessage); Public constructor Create; destructor Destroy; Override; Call test function Callhwndtest:boolean; end;implementation{tcallhwnd}function tcallhwnd.callhwndtest:boolean;begin Result: = PostMessage (Fhwnd, WM_ User_msg, 1, 2) end;constructor tcallhwnd.create;begin Fhwnd: = Allocatehwnd (dousermessage); end;destructor Tcallhwnd.destroy;begin Deallocatehwnd (fhwnd); Inherited;end;procedure Tcallhwnd.dousermessage (var amsg:tmessage); begin If amsg.msg = wm_user_msg Then Begin //amsg.lparam 2 //amsg.wparam 1 //do something end else amsg.result: = DefWindowProc (Fhwnd, Amsg.msg, Amsg.wparam, Amsg.lparam); End;end.
Delphi uses custom handle to process messages