17.01.2011, 13:31
|
|
Let Me Show You
|
|
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
|
|
файл проекта:
Код:
program Project1;
uses
Windows, Messages,
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
var
PreviousInstanceWindow : LongWord;
begin
PreviousInstanceWindow := FindWindow('TfMain',nil);
if PreviousInstanceWindow <> 0 then begin
// if IsIconic(PreviousInstanceWindow) then
SendMessage(PreviousInstanceWindow, WM_USER, 0, 0);
// else
// SetForegroundWindow(PreviousInstanceWindow);
Halt;
end;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
главная форма:
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
procedure WMUSER(var Message: TMessage); message WM_USER;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function SetForegroundWindow(AHandle: THandle): Boolean;
var
AWindow: THandle;
AThreadId: Cardinal;
AProcessId: Cardinal;
begin
AWindow:=GetForegroundWindow;
AThreadId:=GetCurrentThreadId;
AProcessId:=GetWindowThreadProcessId(AWindow, nil);
AttachThreadInput(AThreadId, AProcessId, True);
Result:=Windows.SetForegroundWindow(AHandle);
AttachThreadInput(AThreadId, AProcessId, False);
end;
{ TForm1 }
procedure TForm1.WMUSER(var Message: TMessage);
begin
if not Visible then Show;
ShowWindow(Application.Handle, SW_SHOW);
Application.Restore;
Application.BringToFront;
// SetForegroundWindow(Handle);
end;
end.
только WM_USER+что-то, имхо
__________________
Пишу программы за еду.
__________________
|