S
sixeight
Unregistered / Unconfirmed
GUEST, unregistred user!
1. 有几个不同类的控件,TEdit, TComboBox,动态创建控件时
procedure CreateEdit;
begin
with TEdit.Create(Owner) do
begin
//.......
end;
end;
procedure CreateComboBox;
begin
with TComboBox.Create(Owner) do
begin
//....
end;
end;
可不可能将TEdit、TComboBox用变量来代替,也就是想写成一个过程:
Procedure CreateControl(AControlType: ???)
begin
with AControlType.Create(Owner) do
//.....
end;
2. 有这种类型如 Type TmyType = (mtA, mtB)
本来我这样写:
case DataSet.FieldByName('FmyType').AsInteger of
1: TmyClass.myType := mtA;
2: TmyClass.myType := mtB;
end;
可不可将整型转换为TmyType类型,这样就不用写case了
procedure CreateEdit;
begin
with TEdit.Create(Owner) do
begin
//.......
end;
end;
procedure CreateComboBox;
begin
with TComboBox.Create(Owner) do
begin
//....
end;
end;
可不可能将TEdit、TComboBox用变量来代替,也就是想写成一个过程:
Procedure CreateControl(AControlType: ???)
begin
with AControlType.Create(Owner) do
//.....
end;
2. 有这种类型如 Type TmyType = (mtA, mtB)
本来我这样写:
case DataSet.FieldByName('FmyType').AsInteger of
1: TmyClass.myType := mtA;
2: TmyClass.myType := mtB;
end;
可不可将整型转换为TmyType类型,这样就不用写case了