delphi子窗体重复打开问题解决方法
procedure? TfrmMainForm.OpenForm(FormClass: TFormClass; var fm; AOwner:TComponent);
var
i: integer;
Child:TForm;
begin
for i := 0 to Screen.FormCount -1 do
if Screen.Forms[i].ClassType=FormClass then
begin
Child:=TForm(Screen.Forms[i]);
if Child.WindowState=wsMinimized then
ShowWindow(Child.handle,SW_SHOWNORMAL)
else
ShowWindow(Child.handle,SW_SHOWNA);
if (not Child.Visible) then Child.Visible:=True;
Child.BringToFront;
Child.Setfocus;
TForm(fm):=Child;
exit;
end;
Child:=TForm(FormClass.NewInstance);
TForm(fm):=Child;
Child.Create(application);
end;
//OpenForm(FFormClassList[aindex],aForm,nil); //可不重复打开窗体
本文介绍了一种在Delphi中避免重复打开子窗体的方法,并提供了实用的代码示例。通过检查屏幕上的所有窗体,如果找到指定类型的已打开窗体,则将其激活并置于最前,从而实现窗体的有效管理和用户体验的提升。
2568

被折叠的 条评论
为什么被折叠?



