我是这样创建的 procedure TFrmMain.FrmCreate(Caption : string); var FView : TChildFrm; begin FView := TChildFrm.Create(self); FView.Caption := Caption; FView.Show; end;
to myxfang(小方) 这种方法我试过,这好象是以字窗体的Z轴排序,不是以创建先后循序排序
定义成控件数组,而且要是全局的。 var MDIFrm : array[0..9] of TChiedFrm; 再定义一个全局的整型变量 MDICount 记录当前生成的子窗体个数。
procedure ShowChild(ACaption: string); function GetChildFormByCaption: TForm; var I: Integer; begin for I := 0 to CompnentCount - 1 do if Components[I] is TForm and (TForm(Components[I]).Caption = ACaption) then begin Resut ;= TForm(Components[I]); Exit; end; end; var ChildForm: TForm; begin ChildForm := GetChildFormByName; if ChildForm <> nil then ChildForm.Show else ShowMessage('没有Caption为:'+ACaption+'的子窗') end;
自已写个函数通过子窗体的Caption进行查找显示! procedure TFrmMain.FindShowFrm(aCaption : string); var i:integer; begin for i:=0 to MDIChildCount-1 do begin if MDIChildren[i].caption=aCaption then begin MDIChildren[i].Show; break; end; end; end;
name.show
setActiveWindow(name.handle);
procedure TFrmMain.FrmCreate(Caption : string);
var
FView : TChildFrm;
begin
FView := TChildFrm.Create(self);
FView.Caption := Caption;
FView.Show;
end;
这种方法我试过,这好象是以字窗体的Z轴排序,不是以创建先后循序排序
var MDIFrm : array[0..9] of TChiedFrm;
再定义一个全局的整型变量 MDICount 记录当前生成的子窗体个数。
function GetChildFormByCaption: TForm;
var
I: Integer;
begin
for I := 0 to CompnentCount - 1 do
if Components[I] is TForm and (TForm(Components[I]).Caption = ACaption) then
begin
Resut ;= TForm(Components[I]);
Exit;
end;
end;
var
ChildForm: TForm;
begin
ChildForm := GetChildFormByName;
if ChildForm <> nil then
ChildForm.Show else
ShowMessage('没有Caption为:'+ACaption+'的子窗')
end;
procedure TFrmMain.FindShowFrm(aCaption : string);
var
i:integer;
begin
for i:=0 to MDIChildCount-1 do
begin
if MDIChildren[i].caption=aCaption then
begin
MDIChildren[i].Show;
break;
end;
end;
end;