利用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;

最新文章

  1. artTemplate模板引擎学习实战
  2. C++多线程1
  3. codeforces 490C. Hacking Cypher 解题报告
  4. delphi 数组类型与数组指针的巧妙利用
  5. 关于photoshop钢笔工具中各点对应到“贝塞尔曲线”中的含义(cocos2d-x与iOS)
  6. python 核心编程第六章课后题自己做的答案
  7. mybatis快速入门(六)
  8. 推荐一个利用 python 生成 pptx 分析报告的工具包:reportgen
  9. GC(垃圾处理机制)面试题
  10. centos 安装MySQL全过程
  11. Gym 101775J Straight Master(差分数组)题解
  12. 《汇编语言 基于x86处理器》第八章高级过程部分的代码 - 两种规范计算数组元素的和
  13. Dynamo(Amazon分布式存储引擎)
  14. Android下基于SDL的位图渲染(二)理论篇
  15. XX-net 部署网络
  16. Asis CTF 2015-Car_Market
  17. DataGridView:DataGridView控件清空绑定的数据
  18. 模块讲解----configparser模块(my.cnf配置文件操作)
  19. 用 Sqlmap 识别 WAF
  20. 【hdoj_2079】选课时间(母函数)

热门文章

  1. Java和.NET下socket转换错误记录
  2. jni 之helloworld
  3. python--列表的使用
  4. oracle 事务简介,锁的概念,java访问数据库注意事项
  5. 我的开发框架(WinForm)2
  6. Matlab使用难点记忆
  7. centos install shutter (How to enable Nux Dextop repository on CentOS or RHEL)
  8. SharePoint2013 SharePoint-Hosted 模式 分页方法
  9. JDBC的几个步骤
  10. JAXB - Hello World