Delphi中的GetEnumName和GetEnumValue的使用方法
来源:互联网 发布:淘宝优惠劵 编辑:程序博客网 时间:2024/06/05 11:07
利用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;
0 0
- Delphi中的GetEnumName和GetEnumValue的使用方法
- delphi中GetEnumName和GetEnumValue
- delphi中GetEnumName和GetEnumValue
- GetEnumName与GetEnumValue的用法
- delphi中的ActionList使用方法
- Delphi-Scrollbar控件的使用方法和详解
- Delphi常见的使用方法
- delphi 的EditMask使用方法
- delphi 的EditMask使用方法
- delphi 的EditMask使用方法
- Delphi第三方皮肤组件AlphaControls的下载和使用方法
- Delphi第三方皮肤组件AlphaControls的下载和使用方法
- Delphi&Excel的所有使用方法
- delphi ---MaskEdit的EditMask使用方法
- delphi的正则TPerlRegEx使用方法
- delphi中TTreeView的使用方法
- Delphi TStrings的高级使用方法
- delphi中nil的使用方法
- VB如何才能在win8下运行?
- LeetCode Binary Tree Postorder Traversal(二叉树的后序遍历 非递归实现)
- OpenStack消息队列AMQP技术具体实现 [分析基于icehouse]
- 本文主要介绍ios新建工程,工程中包含文件的作用,以及XCode基本知识,ios项目的运行等信息 iOS学习1:Hello iOS, HelloWorld
- LeetCode Binary Tree Preorder Traversal (二叉树先序遍历非递归)
- Delphi中的GetEnumName和GetEnumValue的使用方法
- 横竖屏自动响应viewWillLayoutSubviews
- Ubuntu12.04配置NVIDIA cuda5.5经验帖
- 字典树
- 安装Java
- 腾讯“扎篱笆”被打成筛子 一分钟内被黑客攻破
- 刘宇凡:关于圈子的只言片语
- Android NDK 配置
- XCode快捷键