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

Delphi中的GetEnumName和GetEnumValue的使用方法的更多相关文章

  1. (转载)c++builder/delphi中透明panel及透明窗口的实现方法_delphi教程

    c++builder/delphi中透明panel及透明窗口的实现方法_delphi教程 可能大多数程序员会问:透明窗口,特别是透明Panel有什么应用价值呢?可别小看它们哦,下面我就来讲讲他们的巨大 ...

  2. 在Delphi中使用C++对象(两种方法,但都要改造C++提供的DLL)

    Delphi是市场上最好的RAD工具,但是现在C++占据着主导地位,有时针对一个问题很难找到Delphi或Pascal的解决方案.可是却可能找到了一个相关的C++类.本文描述几种在Delphi代码中使 ...

  3. 在 Delphi 中判断一个字符是中文的方法

    http://blog.163.com/l1_jun/blog/static/143863882011741124581/ 由于 Delphi2005 支持中文标识符,在编写 PASCAL 词法分析器 ...

  4. Delphi中打开网页连接的几种方法

    https://blog.csdn.net/zisongjia/article/details/69398143 正好要用,做个记录.Mark下. 使用了第一种 uses shellapi proce ...

  5. Delphi中取得汉字的首字母简单方法(十分巧妙)

    //从朝闻道的博客里转载,原文定义AHzStr: String,发现结果为空,后来改成AHzStr: AnsiString就可以了 function GetHzPy(const AHzStr: Ans ...

  6. Delphi中实现文件拷贝的三种方法

    1.调用API函数procedure CopyFile(FromFileName,ToFileName:string);varf1,f2:file;BeginAssignFile(f1,FromFil ...

  7. Delphi中Message消息的三种使用方法(覆盖WndProc,覆盖消息函数,改写WMCommand)

    实例1 unit Unit1; interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Fo ...

  8. Delphi中编辑word

      其他(28)   //启动Word   try     wordapplication1.connect;   except     messagedlg('word may not be ins ...

  9. 在Delphi中使用C++对象(转)

    源:http://blog.csdn.net/henreash/article/details/7352335 Delphi是市场上最好的RAD工具,但是现在C++占据着主导地位,有时针对一个问题很难 ...

随机推荐

  1. stap-prep 需要安装那些内核符号

    [root@server-mysql ~]# Need to install the following packages:kernel-debuginfo-2.6.32-279.el6.x86_64 ...

  2. Jordan Lecture Note-6: The Solutions of Nonlinear Equation.

    The Solutions of Nonlinear Equation 本文主要介绍几种用于解非线性方程$f(x)=0$的一些方法. (1) Bisection Method. 算法: step 1: ...

  3. QT连接多种数据库f方法及测试

    QT提供了对多种数据库的访问支持,对SQL Server也可以通过ODBC来进行访问.要想顺利访问SQL Server. 首先要保证以下几点:1. QT编译时已经编译了QtSql2. 编译了ODBC插 ...

  4. dd,实现系统备份

    一.dd的使用 dd命令的解释dd:用指定大小的块拷贝一个文件,并在拷贝的同时进行指定的转换. 注意:指定数字的地方若以下列字符结尾则乘以相应的数字:b=512:c=1:k=1024:w=2 参数: ...

  5. C#_Ajax_分页

    using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace MvcTe ...

  6. 最新 Sublime Text 3 Package Control 安装方法

    相信看到这个帖子的童鞋,一般至少对 Sublime Text 有所了解了,废话不多讲,个人在 ST2 还没用好的时候, Sublime Text 3 又横空出世了,不过现在 ST3 还是 beta 版 ...

  7. codereview介绍

    1. 定义: Code review is systematic examination (often known as peer review) of computer source code. I ...

  8. [COCOS2DX]COCOS命令新建项目+编译安卓项目并成功运行

    全程搭建过程参考网址: http://blog.csdn.net/lengxue789/article/details/38116475 http://blog.csdn.net/cbbbc/arti ...

  9. five kinds of IPC methods

    Shared memory permits processes to communicate by simply reading and writing to a specified memory l ...

  10. mac mysql error You must reset your password using ALTER USER statement before executing this statement.

    安装完mysql 之后,登陆以后,不管运行任何命令,总是提示这个 step 1: SET PASSWORD = PASSWORD('your new password'); step 2: ALTER ...