procedure TMainForm.FormCreate(Sender: TObject);
begin
// Add some example enumerated types
with lbSamps.Items do
begin
AddObject('TButtonState', TypeInfo(TButtonState));
AddObject('TFormStyle', TypeInfo(TFormStyle));
AddObject('Boolean', TypeInfo(Boolean));
end;
end;procedure TMainForm.lbSampsClick(Sender: TObject);
var
OrdTypeInfo: PTypeInfo;
OrdTypeData: PTypeData; TypeNameStr: String;
TypeKindStr: String;
MinVal, MaxVal: Integer;
i: integer;
begin
memInfo.Lines.Clear;
with lbSamps do
begin // Get the TTypeInfo pointer
OrdTypeInfo := PTypeInfo(Items.Objects[ItemIndex]);
// Get the TTypeData pointer
OrdTypeData := GetTypeData(OrdTypeInfo); // Get the type name string
TypeNameStr := OrdTypeInfo.Name;
// Get the type kind string
TypeKindStr := GetEnumName(TypeInfo(TTypeKind), Integer(OrdTypeInfo^.Kind)); // Get the minimum and maximum values for the type
MinVal := OrdTypeData^.MinValue;
MaxVal := OrdTypeData^.MaxValue;
// Add the information to the memo
with memInfo.Lines do
begin
Add('Type Name: '+TypeNameStr);
Add('Type Kind: '+TypeKindStr); Add('Min Val: '+IntToStr(MinVal));
Add('Max Val: '+IntToStr(MaxVal)); // Show the values and names of the enumerated types
if OrdTypeInfo^.Kind = tkEnumeration then
for i := MinVal to MaxVal do
Add(Format(' Value: %d Name: %s', [i, GetEnumName(OrdTypeInfo, i)])); end;
end;
end;
begin
// Add some example enumerated types
with lbSamps.Items do
begin
AddObject('TButtonState', TypeInfo(TButtonState));
AddObject('TFormStyle', TypeInfo(TFormStyle));
AddObject('Boolean', TypeInfo(Boolean));
end;
end;procedure TMainForm.lbSampsClick(Sender: TObject);
var
OrdTypeInfo: PTypeInfo;
OrdTypeData: PTypeData; TypeNameStr: String;
TypeKindStr: String;
MinVal, MaxVal: Integer;
i: integer;
begin
memInfo.Lines.Clear;
with lbSamps do
begin // Get the TTypeInfo pointer
OrdTypeInfo := PTypeInfo(Items.Objects[ItemIndex]);
// Get the TTypeData pointer
OrdTypeData := GetTypeData(OrdTypeInfo); // Get the type name string
TypeNameStr := OrdTypeInfo.Name;
// Get the type kind string
TypeKindStr := GetEnumName(TypeInfo(TTypeKind), Integer(OrdTypeInfo^.Kind)); // Get the minimum and maximum values for the type
MinVal := OrdTypeData^.MinValue;
MaxVal := OrdTypeData^.MaxValue;
// Add the information to the memo
with memInfo.Lines do
begin
Add('Type Name: '+TypeNameStr);
Add('Type Kind: '+TypeKindStr); Add('Min Val: '+IntToStr(MinVal));
Add('Max Val: '+IntToStr(MaxVal)); // Show the values and names of the enumerated types
if OrdTypeInfo^.Kind = tkEnumeration then
for i := MinVal to MaxVal do
Add(Format(' Value: %d Name: %s', [i, GetEnumName(OrdTypeInfo, i)])); end;
end;
end;
for i:= A1 to LETTER do
ComboBox.Items.Add(GetEnumName(i));
TypInfo;type
TTest = (a, b, c, d, haha, yeah);
procedure TForm1.Button1Click(Sender: TObject);
var
ti: PTypeInfo;
td: PTypeData;
i: Integer;
begin
ti := TypeInfo(TTest);
td := GetTypeData(ti);
for i := td^.MinValue to td^.MaxValue do
Combobox1.Items.Add(GetEnumName(ti, i));
end;
如何把TQRPAGE 的TQRPAPERSIZE取回来