DFW不至于堕落到这种地步吧?yy2001的也能算程序吗?对于字符串类型的变量能用CASE语句
吗?真是服了你们!!
procedure TForm1.Button1Click(Sender: TObject);
var
i : Integer;
begin
for i:=0 to Screen.FormCount-1 do begin
if UpperCase(Screen.Forms.Name) = UpperCase(Edit1.Text) then begin
Screen.Forms.Show;
break;
end;
end;
end;
var
i : Integer;
begin
for i:=0 to application.ComponentCount-1 do begin
//注意大小写的匹配
if Application.Components.Name=Edit1.text then
(Application.Components as TForm).show;
//Tform(application.Components).Show; //用此行也可
end;
procedure button1click(sender:Tobject);
var
FormClass:TformClass;
CurrForm:TForm;
begin
formClass:=GetClass(Edit1.text);
if FormClass<>nil then
begin
CurrForm:=FormClass.Create(Application);
CurrForm.show;
end;
end;
在主窗体的create事件中,调用
registclasses,把要用到的所有类窗体类注册,否则,用getClass得不到结果!注意
edit中输入的要为窗体的类名,如Tform1,Tform2.如果一定要输入form1这样的
可以用getclass('T'+edit1.text)