Var OldWindowProc: Pointer;
MyMsg: LongInt;
Function NewWindowProc(WH: hWnd;Msg,PW,PL:LongInt):LongInt stdcall;
Begin
If Msg=MyMsg Then
Begin
SendMessage(Application.Handle,WM_SYSCOMMAND,SC_RESTORE,0);
SetForegroundWindow(Application.Handle);
Result:=0;
exit;
End;
Result:=CallWindowProc(OldWindowProc,WH,Msg,PW,PL);
End;
No Evento OnCreate do form principal coloque:
MyMsg:=RegisterWindowMessage('X10APP');
OldWindowProc:=Pointer(SetWindowLong(Handle, GWL_WNDPROC, LongInt(@NewWindowProc)));
No Evento onDestroy do form principal coloque:
SetWindowLong(Handle,GWL_WNDPROC,LongInt(OldWindowProc));
No seu Arquivo *.dpr, coloque:
Cláusula Uses: Windows
e abaixo de {$R *.RES} coloque:
begin
//***************************************************
CreateMutex(NIL,False,'X10APP');
If GetLastError = ERROR_ALREADY_EXISTS Then
Begin
SendMessage(HWND_BROADCAST,
RegisterWindowMessage('X10APP'),0,0);
Halt(0);
End;
//***************************************************
{Coloque no seu projeto essa parte que esta acima}
Application.Initialize;
Application.CreateForm(TfrmPrincipal, frmPrincipal);
Application.Run;
end.
Assinar:
Postar comentários (Atom)
Nenhum comentário:
Postar um comentário