procedure TMainForm.ActionNewExecute(Sender: TObject);
var
OldChildForm, NewChildForm: TChildForm; // TChildForm是自建的子窗体类
begin
OldChildForm := TChildForm(ActiveMDIChild); // 取得当前活动子窗口
Inc (Counter);
NewChildForm := TChildForm.Create (Self);
NewChildForm.Caption :=
LowerCase (ExtractFilePath (Application.Exename)) +
'text' + IntToStr (Counter) + '.txt';
if Assigned(OldChildForm) then OldChildForm.Show // 重新显示旧的窗口
else NewChildForm.Show;
end;