Delphi DLL动态调用的子窗体怎么判断子窗体是否存在
Delphi 主窗体动态调用DLL的一个子窗体。 怎么判断DLL子窗体是否已存在(在主窗体中已打开),
如果打开则只需要置前
动态调用代码如下:
// DllFormName 为 DLL中的一个子窗体
// ParentForm 为 主窗体
Application := App;
TheClass := GetClass(DllFormName);
if (TheClass = nil) then exit;
if TheClass.InheritsFrom(TForm) then
begin
try
begin
aForm := TForm(TheClass.Create).Create(ParentForm);
aForm.FormStyle := fsMDIChild;
aForm.Show;
aForm.BringToFront;
finally
FreeLibrary(ParentForm.Handle);
end;
end;