请问:
1: TFormClass = class of TForm;是不是等同于 TFormClass = class(TForm);
TFormClass和TForm有什么不同啊;
2:string和stringlist有什么区别
1: TFormClass = class of TForm;是不是等同于 TFormClass = class(TForm);
TFormClass和TForm有什么不同啊;
2:string和stringlist有什么区别
1:TFormClass = class of TForm;//-->TFormClass == TForm
TFormClass = class(TForm); //-->TFormClass 继承至 TForm
2:string是一般在字符串;//如str := 'abc' ;
stringlist是字符串列表,可以像数组一样访问的,
使用时要创建的,最后要释放
strList := TSTringList.Create;
strList.Add('abc');
strList.Add('123');
//...
strList.Free;
string是保存字符串用的,而stringlist是TStrings的派生类TStringList声明的对象,是字符串数组,它能保存一系列的字符串,使用时要自己创建,自己销毁,String则不用!
type TControlClass = class of TControl;
编写一个创建TControl的函数
function CreateControl(ControlClass: TControlClass;
const ControlName: string; X, Y, W, H: Integer): TControl;
begin
Result := ControlClass.Create(MainForm);
with Result do
begin
Parent := MainForm;
Name := ControlName;
SetBounds(X, Y, W, H);
Visible := True;
end;
end;
调用:
CreateControl(TEdit, 'Edit1', 10, 10, 100, 20);
这里,Tedit是TControl的子类就可以正常运行。