Implementation
uses Mainunit;
// unit der Mainform
var
OriginalWndProc: Pointer;
CurrentFormHandle: hWnd;
function FormX_HookedWndProc(FormHandle: hWnd; MessageID: LongInt;
ParamW: LongInt; ParamL: LongInt): LongInt
stdcall;
begin
if MessageID = UniqueAppMsg
then
begin
SendMessage(Application.Handle, WM_SYSCOMMAND, SC_RESTORE, 0);
SetForegroundWindow(Application.Handle);
SendMessage(CurrentFormHandle, WM_SYSCOMMAND, SC_RESTORE, 0);
Result := 0;
end
else
Result := CallWindowProc(OriginalWndProc, FormHandle, MessageID, ParamW, ParamL);
end;
procedure TFormX.FormCreate(Sender: TObject);
begin
CurrentFormHandle:=FormX.Handle;
OriginalWndProc := Pointer(SetWindowLong(CurrentFormHandle, GWL_WNDPROC,
LongInt(@FormX_HookedWndProc)));
end;
procedure TFormX.FormDestroy(Sender: TObject);
begin
SetWindowLong(CurrentFormHandle, GWL_WNDPROC, LongInt(OriginalWndProc));
end;