unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, afxCodeHook;
type
TForm1 =
class(TForm)
procedure FormActivate(Sender: TObject);
end;
var
Form1: TForm1;
ShowWindowNextHook:
function(hWnd: HWND; nCmdShow: Integer): LongBool;
stdcall;
function ShowWindowHookProc(hWnd: HWND; nCmdShow: Integer): LongBool;
stdcall;
implementation
{$R *.dfm}
function ShowWindowHookProc(hWnd: HWND; nCmdShow: Integer): LongBool;
stdcall;
begin
if nCmdShow = SW_SHOWNORMAL
then
Result := ShowWindowNextHook(hWnd, SW_SHOWNOACTIVATE)
else
Result := ShowWindowNextHook(hWnd, nCmdShow);
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
ShowMessage('
Test!');
end;
initialization
HookCode('
user32', '
ShowWindow', @ShowWindowHookProc, @ShowWindowNextHook);
finalization
UnHookCode(@ShowWindowNextHook);
end.