当然不行,因为参数不是字符串var
form2:TForm2;
begin
if not assigned(form2) then
form2:=TForm2.Create(Application);
end;
form2:TForm2;
begin
if not assigned(form2) then
form2:=TForm2.Create(Application);
end;
解决方案 »
- 鼠标箭头在图片上,图片切换为另外一副,当不在上面,又切换回原来的?自己老做不好,请教了
- utf-8 解码 delphi (帮顶有分)
- 我可以定義1個1維數組. 然後數組里的每個元素都是1個2維數組. 可以嗎?怎麼定義
- 请教Sendmessage发送什么消息使用TPageControl隐藏的页面显示出来
- 公共函数 如何得知 调用它的窗体的属性?
- 如何得到一个dll文件的版本,厂商,最后更新日期等信息?
- 急急急!为什么在我自己写的过程(或函数)里写:richedit1.lines.text之类的东西,编译的时候说richedit1没有定义?
- 各位大虾,请给我推荐几本介绍网络编程的书吧
- 请问各位大哥在哪可买到MAPX的书???
- 组卷系统 Delphi+SQL Server
- 请问如何屏蔽掉[开始]按钮
- 关于不规则窗体的问题
if form2<>nil then application.create(tform2,form2);、
至于指字符串转变为form
用if 语句判断即可
var i:integer;
begin
Result:=false;
for i:=0 to Application.ComponentCount-1 do
if Application.Components[i].ClassNameIs(form) then
begin
Result:=true;
Exit;
end;
end;
//InternalFindShowForm(FormClass, Caption, True);
function InternalFindShowForm(FormClass: TFormClass;
const Caption: string; Restore: Boolean): TForm;
var
I: Integer;
begin
Result := nil;
for I := 0 to Screen.FormCount - 1 do begin
if Screen.Forms[I] is FormClass then
if (Caption = '') or (Caption = Screen.Forms[I].Caption) then begin
Result := Screen.Forms[I];
Break;
end;
end;
if Result = nil then Application.CreateForm(FormClass, Result);
with Result do begin
if Restore and (WindowState = wsMinimized) then WindowState := wsNormal;
Show;
end;
end;
function InternalFindShowForm(const WindowsName: string; Restore: Boolean): TForm;
var
I: Integer;
begin
Result := nil;
for I := 0 to Screen.FormCount - 1 do begin
if Screen.Forms[I] is TForm then
if (WindowsName = '') or (WindowsName = Screen.Forms[I].Name) then begin
Result := Screen.Forms[I];
Break;
end;
end;
if Result = nil then Application.CreateForm(TForm, Result);
with Result do begin
if Restore and (WindowState = wsMinimized) then WindowState := wsNormal;
Show;
end;
end;
应用实例:
procedure TForm1.Bitbtn1Click(Sender:TObject)
var
StrTemp:String;
begin
StrTemp:='Form2';//Form2已经存在,现在准备创建
InternalFindShowForm(StrTemp,True);
end;
var
Form1:TForm;
begin
Form1 := TForm.Create(Self);
Form1.Name := 'frmMDIChild1' ;
end;