F
fanwendou
Unregistered / Unconfirmed
GUEST, unregistred user!
//再program 中的代码
program Project1;
uses
Windows,
Messages,
Forms,
SysUtils,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
var
H:THandle;
const WM_RESTOREFORM=WM_USER+1206;
begin
CreateMutex(nil, True, '1232');
if GetLastError = ERROR_ALREADY_EXISTS then
begin
H:=FindWindow('TForm1',nil);
if H<>0 then
postMessage(H,WM_RESTOREFORM,0,0);
Exit;
// 退出
end;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
//在form1中的代码
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
const WM_RESTOREFORM=WM_USER+1206;
type
TForm1 = class(TForm)
private
procedure RestoreForm(var Msg:TMessage);message WM_RESTOREFORM;
//恢复窗体
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure tform1.RestoreForm(var Msg: TMessage);
begin
Application.Restore;
end;
end.
为什么我RestoreForm得不到运行,希望你运行以后在回答.
program Project1;
uses
Windows,
Messages,
Forms,
SysUtils,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
var
H:THandle;
const WM_RESTOREFORM=WM_USER+1206;
begin
CreateMutex(nil, True, '1232');
if GetLastError = ERROR_ALREADY_EXISTS then
begin
H:=FindWindow('TForm1',nil);
if H<>0 then
postMessage(H,WM_RESTOREFORM,0,0);
Exit;
// 退出
end;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
//在form1中的代码
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
const WM_RESTOREFORM=WM_USER+1206;
type
TForm1 = class(TForm)
private
procedure RestoreForm(var Msg:TMessage);message WM_RESTOREFORM;
//恢复窗体
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure tform1.RestoreForm(var Msg: TMessage);
begin
Application.Restore;
end;
end.
为什么我RestoreForm得不到运行,希望你运行以后在回答.