TMyForm = class(TForm)
...
End;我想要一个过程Show(TMyForm);
我如何写这个过程呢!
...
End;我想要一个过程Show(TMyForm);
我如何写这个过程呢!
解决方案 »
- [散分1]工作极度郁闷------
- TStringGrid控件的一点用法问题?
- 菜鸟问题:这小段代码错在哪里?
- delphi 的sql explorer和desktop无法使用?
- 刚做了一个取电脑CPU序列号、网卡MAC地址、主板BIOS、操作系统序列号的Delphi控件
- 请高手帮助....!!!
- 怎样输入一些特殊符号,如“‰”?
- 请问如何遍历菜单?
- 从SQL SERVER6.5升级到7.0的,请大家谈谈注意事项及操作。100分
- 谁要《delphi informant magazine1995-2000》的请进来,非宽带勿进!
- 关于自绘窗体标题栏的问题出现黑影块
- toolbar如何动态添加删除TToolButton?
begin
TMyForm.show;
end;
用这个过程,是为了判断主窗体的所有子窗体中是否有这个类的实例,有的话就显示,没的话就创建并且显示。
procedure ShowAForm(aForm:TMyForm)
begin
if not Assigned(aForm) then aForm:=TMyForm.Create(nil);
aForm.show;
end;
var
Instance :TComponent;
begin
Instance := TForm(aFormClass.NewInstance);
try
Instance.Show();
except
//
end;
end;
begin
AFormClass.Create(Application).Show;
end;调用的时候是
ShowForm(TfrmMain);这样就会出现上面的错误了!
procedure Show(aForm :TMyForm);
begin
if not Assigned(aForm) then
aForm:=TMyForm.Create(Self);
aForm.Show;
end;
if is class, you should define a class type like TFormClass = class of TForm;
TfrmMain.ShowForm(AFormClass: TForm); //AFormClass is instance of TForm not class, you should understand this
please refer to Application.CreateForm(InstanceClass: TComponentClass; var Reference)
the first parameter is class, the second parameter is instance