在主窗口中interface节加入
const
CM_restore=wm_user+$1000;
MYAPPNAME="My Delphi Program";
并在Form的定义Public节中加入
procedure CreateParams(var Params:TCreateParams);override;
procedure RestoreRequest(var message:TMessage);message CMRESTORE;
在implementation节中加入
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;
2对DPR文件的改动
在Uses 节中添加windows,message这两个单元中加入下列语句。注意两个文件中的常量必须一致CM_RESTORE,MYAPPNAME
const
CM_RESTORE=WM_USER+$1000;
MYAPPNAME="My Delphi Program";
var
RvHandle:hWnd;
rvhandle:=findwindow(MYAPPNAME,NIL);
if rvhandel>0 then
begin
PostMessage(Rvhandle,CM_RESTORE,0,0);
exit;
end;