在主窗口中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;
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;
解决方案 »
- 求delphi毕业设计
- 发现一个新玩意儿
- .......................................................................................
- TIdTcpClient和TIdTcpServer传递XML数据的问题~~!
- 有关SQL数据库查询某条记录并且能定位的问题!
- 在《程序员增值合订本》一书附带的DELPHI7为何不能安装!!!!!进来有分!!
- 问个简单的问题:在winxp/delphi7下如何实现用enter代替tab功能?
- 关于与(and)的问题5点前在线等待!
- 我想做数据库的只读查表(单表,有过滤条件)操作,使用哪种方式最快?
- 烦死我了!程序保存后却不能运行了!一定给分!
- 計算字段求值問題﹗﹗
- 好奇怪,通过SQL建的表与Access里建表怎么有这样的区别???
如果找到就不要运行第二次了。一个朋友写的例子:var Mutex: THandle;
begin
Mutex := CreateMutex(nil, True, 'SingleApp'); //SingleApp,一个比较特殊的名字
if GetLastError <> ERROR_ALREADY_EXISTS then
begin
Application.Initialize;
end;