delphi中多文档子窗体的创建方法是怎样呢
1个回答
展开全部
unit mainfrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, Menus, ExtCtrls, RzPanel, ImgList, RzButton,
RzStatus, RzCommon, StdCtrls, jpeg, DB, ADODB,shellapi,
Buttons, RzLine, RzGroupBar,md5,inifiles, SkinCaption, WinSkinData;
type
TMAIN = class(TForm)
private
{ Private declarations }
public
function FindForm(caption: string): bool;
{ Public declarations }
end;
var
MAIN: TMAIN;
implementation
{$R *.dfm}
//-----------通过用户定义的函数,判断窗体是否已存在--------------------
function Tmain.FindForm(caption: string): bool;
var
i:integer;
begin
result:=true;
for i:=0 to main.MDIChildCount do
begin
// 通过对窗体标题判断窗体是否存在
if main.MDIChildren[i].Caption=caption then
begin
//如果窗体已存在,则恢复窗体,并返回true
SendMessage(mdichildren[i].Handle, WM_SYSCOMMAND, SC_RESTORE, 0);
mdichildren[i].Enabled:=true;
mdichildren[i].Show;
mdichildren[i].SetFocus;
result:=true;
break;
end
else
//如窗体不存在,则返回false,程序将创建窗体
result:=false;
end
end;
//-------------打开操作人员设置窗体----------
procedure TMAIN.N2Click(Sender: TObject);
Var
newform:Tcaozuorenyuan;
begin
if FindForm('操作人员设置')=false then
begin
newform:=Tcaozuorenyuan.Create(application);
newform.Caption:='操作人员设置';
end;
end;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, Menus, ExtCtrls, RzPanel, ImgList, RzButton,
RzStatus, RzCommon, StdCtrls, jpeg, DB, ADODB,shellapi,
Buttons, RzLine, RzGroupBar,md5,inifiles, SkinCaption, WinSkinData;
type
TMAIN = class(TForm)
private
{ Private declarations }
public
function FindForm(caption: string): bool;
{ Public declarations }
end;
var
MAIN: TMAIN;
implementation
{$R *.dfm}
//-----------通过用户定义的函数,判断窗体是否已存在--------------------
function Tmain.FindForm(caption: string): bool;
var
i:integer;
begin
result:=true;
for i:=0 to main.MDIChildCount do
begin
// 通过对窗体标题判断窗体是否存在
if main.MDIChildren[i].Caption=caption then
begin
//如果窗体已存在,则恢复窗体,并返回true
SendMessage(mdichildren[i].Handle, WM_SYSCOMMAND, SC_RESTORE, 0);
mdichildren[i].Enabled:=true;
mdichildren[i].Show;
mdichildren[i].SetFocus;
result:=true;
break;
end
else
//如窗体不存在,则返回false,程序将创建窗体
result:=false;
end
end;
//-------------打开操作人员设置窗体----------
procedure TMAIN.N2Click(Sender: TObject);
Var
newform:Tcaozuorenyuan;
begin
if FindForm('操作人员设置')=false then
begin
newform:=Tcaozuorenyuan.Create(application);
newform.Caption:='操作人员设置';
end;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询