Delphi中的GetEnumName和GetEnumValue的使用方法
2024-09-10 17:35:51
利用TypInfo单元的GetEnumName和GetEnumValue可以遍历任意枚举类型,并获取其名称和值。下面是示例Demo。
uses TypInfo;
...
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;
最新文章
- artTemplate模板引擎学习实战
- C++多线程1
- codeforces 490C. Hacking Cypher 解题报告
- delphi 数组类型与数组指针的巧妙利用
- 关于photoshop钢笔工具中各点对应到“贝塞尔曲线”中的含义(cocos2d-x与iOS)
- python 核心编程第六章课后题自己做的答案
- mybatis快速入门(六)
- 推荐一个利用 python 生成 pptx 分析报告的工具包:reportgen
- GC(垃圾处理机制)面试题
- centos 安装MySQL全过程
- Gym 101775J Straight Master(差分数组)题解
- 《汇编语言 基于x86处理器》第八章高级过程部分的代码 - 两种规范计算数组元素的和
- Dynamo(Amazon分布式存储引擎)
- Android下基于SDL的位图渲染(二)理论篇
- XX-net 部署网络
- Asis CTF 2015-Car_Market
- DataGridView:DataGridView控件清空绑定的数据
- 模块讲解----configparser模块(my.cnf配置文件操作)
- 用 Sqlmap 识别 WAF
- 【hdoj_2079】选课时间(母函数)
热门文章
- Java和.NET下socket转换错误记录
- jni 之helloworld
- python--列表的使用
- oracle 事务简介,锁的概念,java访问数据库注意事项
- 我的开发框架(WinForm)2
- Matlab使用难点记忆
- centos install shutter (How to enable Nux Dextop repository on CentOS or RHEL)
- SharePoint2013 SharePoint-Hosted 模式 分页方法
- JDBC的几个步骤
- JAXB - Hello World