procedure TMainForm.N1Click(Sender: TObject); begin if self.FindComponent('FrmOperator')<>nil then begin FrmOperator.BringToFront; beep; exit; end else begin FrmOperator :=TFrmOperator.Create(Self); FrmOperator.show; end; end;
if not Assigned(Form1) then //判別是否已創建
TO foxyy 多谢你的回复,如果窗口的Name一样,但Caption不一样,又怎能样区别呢?
function TMainForm.ExistsForm(MDIFormCaption:String):boolean; var i:byte; begin result:=true; for i:=0 to MDIChildCount-1 do begin if MDIChildren[i].Caption=MDIFormCaption then result:=false; end; end;
begin
if self.FindComponent('FrmOperator')<>nil then
begin
FrmOperator.BringToFront;
beep;
exit;
end else
begin
FrmOperator :=TFrmOperator.Create(Self);
FrmOperator.show;
end;
end;
多谢你的回复,如果窗口的Name一样,但Caption不一样,又怎能样区别呢?
var
i:byte;
begin
result:=true;
for i:=0 to MDIChildCount-1 do
begin
if MDIChildren[i].Caption=MDIFormCaption
then result:=false;
end;
end;