WinAPI
Как перехватывать сообщения и обрабатывать их перед запуском приложенияЭтот код демонстрирует как получать сообщения Windows перед созданием окна приложения.
program Project1;
uses
Forms, messages, wintypes, winprocs, Unit1 in 'UNIT1.PAS' {Form1};
{$R *.RES}
var
OldWndProc: TFarProc;
function NewWndProc(hWndAppl: HWnd; Msg, wParam: Word; lParam: Longint): Longint; export;
begin
result := 0; { Возвращаемое значение по умолчанию WndProc }
{*** Handle messages here; The message number is in Msg ***}
result := CallWindowProc(OldWndProc, hWndAppl, Msg, wParam, lParam);
end;
begin
Application.CreateForm(TForm1, Form1);
OldWndProc := TFarProc(GetWindowLong(Application.Handle, GWL_WNDPROC));
SetWindowLong(Application.Handle, GWL_WNDPROC, longint(@NewWndProc));
Application.Run;
end.
|