delphi如何转换ModalResult属性? [英] How does delphi convert ModalResult properties?

查看:129
本文介绍了delphi如何转换ModalResult属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望这是一个快速的例子,并且如果您知道如何就很容易 ...

Hopefully this is a quick one, and "Easy if you know how"...

我正在编写某种序列化/脚本类来生成表单在运行过程中,我尝试在前一天设置TColor并收到错误
clBtnFace不是有效的整数值或类似的内容,发现使用的常量在属性中已注册,以便可以将它们转换为整数,因此我添加了代码以获取转换器并使用它。

I'm writing some kind of Serialization/Scripting class to generate forms on the fly, I tried setting a TColor the other day and got an error clBtnFace is not a valid integer value or something like that and found that the constants used in properties are registered so that they can be converted to integer, and so I added code to fetch the converter and use it.

现在,我对ModalResult属性,但我不知道DFM解串器如何处理此属性?有什么想法将 mrOK 转换为整数吗?

Now today I have a similar issue with the ModalResult property but I can't work out how the DFM deserializer handles this property? Any ideas how it converts mrOK into an integer?

编辑

没有太多例子可以提供:

There isn't much of an example to give:

PropInfo := GetPropInfo(Instance, PropertyName);
SetPropValue(Instance, PropInfo, PropertyValue);

在这种情况下,实例为TButton,PropertyName为'ModalResult',PropertyValue为'mrOK'

Where in this case Instance is a TButton, PropertyName is 'ModalResult' and PropertyValue is 'mrOK'

推荐答案

它不需要:

const
  { Dialog Box Command IDs }
  {$EXTERNALSYM IDOK}
  IDOK = 1;          ID_OK = IDOK;

const
  mrNone     = 0;
  mrOk       = idOk;

type
  TModalResult = Low(Integer)..High(Integer);

TModalResult在某种程度上是Integer的子范围,而mrOK只是Integer常数。

TModalResult is in someway a subrange of Integer and mrOK is just an Integer constant.

这篇关于delphi如何转换ModalResult属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆