delphi中GetEnumName和GetEnumValue
来源:互联网 发布:java split空格 编辑:程序博客网 时间:2024/06/05 04:12
利用TypInfo单元的GetEnumName和GetEnumValue可以遍历任意枚举类型,并获取其名称和值。下面是示例Demo。
procedure TForm1.btnTestClick(Sender: TObject);
var
p: PTypeData;
i: Integer;
s: String;
pt: PTypeInfo;
begin
ListBox1.Items.Clear;
pt := TypeInfo(TWindowState);
if pt.Kind <> tkEnumeration then begin
ShowMessage('不是枚举类型');
Exit;
end;
p := GetTypeData(TypeInfo(TWindowState));
//将获取的枚举类型信息,以枚举名=枚举值的形式加入到ListBox中
ListBox1.Items.beginUpdate;
try
for i := p.MinValue to p.MaxValue do begin
S := GetEnumName(pt,i);
ListBox1.Items.Values[S] := IntToStr(GetEnumValue(pt, S));
end;
finally
ListBox1.Items.EndUpdate;
end;
end;
阅读全文
0 0
- delphi中GetEnumName和GetEnumValue
- delphi中GetEnumName和GetEnumValue
- Delphi中的GetEnumName和GetEnumValue的使用方法
- GetEnumName与GetEnumValue的用法
- GetEnumName应用
- __delphirtti System::Typinfo::GetEnumName
- Delphi中initialization和finalization
- Delphi中initialization和finalization
- Delphi中initialization和finalization
- Delphi中initialization和finalization
- delphi中ActiveX 和 Web
- Delphi中initialization和finalization
- Delphi中ExtractFileName和ExtractFilePath
- Delphi中initialization和finalization
- Delphi中initialization和finalization
- Delphi XE8中Delphi和JAVA数据类型对应关系!
- 在Delphi中备份和还原数据库
- delphi中对象的create和free- -
- 窗口看门狗的真正作用
- 数字货币钱包POS算法挖矿开发指南
- nfs 基础1
- CODE[VS]3306 水果姐逛水果街3 树链剖分+线段树
- 漫谈CRM体系化建设4 – 如何服务客户
- delphi中GetEnumName和GetEnumValue
- leetcode Different Ways to Add Parentheses
- 上证50指数和沪深300指数
- PullToRefreshListView跟banner的结合使用
- <a>标签中href的几种用法
- 天天学Linux命令44--netstat命令
- 四种古典密码的C++实现(1)-----Hill密码
- C++中cin、cin.get()、cin.getline()、getline()、gets()等函数的用法
- 用户表(查询数据 、添加数据 、排序 、点击删除 、修改密码 、批量删除 、全部删除)