![]() |
|
|
|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
|
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
#2
|
|||
|
|||
|
Я делал так.
В файле проекта: Код:
function AllowSetForegroundWindow(dwProcessId: DWORD): BOOL; stdcall; external 'user32.dll';
function CanStart : Boolean;
var
hMutex : THandle;
begin
Result := True;
WndMessage := RegisterWindowMessage(PChar(GetMessageName));
hMutex := CreateMutex(Nil, True, PChar(GetMutexName));
If hMutex<>0 Then
If GetLastError=ERROR_ALREADY_EXISTS Then
Begin
AllowSetForegroundWindow(DWORD(-1));
PostMessage(HWND_BROADCAST,WndMessage,0,0);
Result := False;
End;
end;
begin
If CanStart Then
Begin
Application.Initialize;
Application.Title := 'Visual Reminder';
Application.CreateForm(TMainForm, MainForm);
Application.HookMainWindow(MainForm.HookMessageProc);
Application.Run;
End;
end.В главной форме: Код:
type
TMainForm = class TForm
..
function HookMessageProc(var Message : TMessage) : Boolean;
end;
var
MainForm: TMainForm;
WndMessage : Cardinal;
function TMainForm.HookMessageProc(var Message: TMessage): Boolean;
begin
Result := False;
If Message.Msg = WndMessage Then
Begin
TrayIcon.ShowMainForm;
Application.BringToFront;
SetForegroundWindow(Self.Handle);
Result := True;
End;
end;Надеюсь, ничего не забыл... |