program Project1;
uses
Windows,
Messages,
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.RES}
const
CM_RESTORE = WM_USER + $1000;
MYAPPNAME = 'duchengfu';
var
RvHandle:integer;
begin
RvHandle := FindWindow(MYAPPNAME,nil);
if RvHandle > 0 then
begin
PostMessage(RvHandle, CM_RESTORE, 0, 0);
Exit;
end;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
const
CM_RESTORE = WM_USER + $1000;
MYAPPNAME = 'duchengfu'
type
TForm1 = class(TForm)
private
{ Private declarations }
public
procedure CreateParams(var Params: TCreateParams);override;
procedure RestoreRequest(var message: TMessage);message CM_RESTORE;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.WinClassName := MYAPPNAME;
end;
procedure TForm1.RestoreRequest(var message: TMessage);
begin
if IsIconic(Application.Handle) = TRUE then
Application.Restore
else
Application.BringToFront;
end;
end.
看清楚一点即可