delphi RTTI的主要函数和应用示例
2012-02-09 11:44
447 查看
delphi 的RTTI为面向对象的编程提供的极大的方便,我们可以不用管对象的类型,只要通过RTTI的方法判断是否有我们需要改变的属性名和属性对象,以下是主要函数
⊙ GetTypeData 函数
⊙ GetPropInfo 函数
⊙ FindPropInfo 函数
⊙ GetPropInfos 函数
⊙ SortPropList 函数
⊙ GetPropList 函数
------------------------------------------------------
⊙ GetObjectPropClass 函数
⊙ PropType / PropIsType 函数
⊙ IsPublishedProp 函数
⊙ IsStoredProp 函数
⊙ FreeAndNilProperties 函数
⊙ SetToString / StringToSet 函数
⊙ GetEnumName / GetEnumValue / GetEnumNameValue 函数
示例1:一键设置所有控件的CustomHint属性(delphi 2010 +)
示例2:一键设置所有控件的输入(delphi 7+)
使用RTTI方法需要引用TypInfo单元,更多RTTI的应用,请下载
RTTI深度应用
部分演示代码
⊙ GetTypeData 函数
⊙ GetPropInfo 函数
⊙ FindPropInfo 函数
⊙ GetPropInfos 函数
⊙ SortPropList 函数
⊙ GetPropList 函数
------------------------------------------------------
⊙ GetObjectPropClass 函数
⊙ PropType / PropIsType 函数
⊙ IsPublishedProp 函数
⊙ IsStoredProp 函数
⊙ FreeAndNilProperties 函数
⊙ SetToString / StringToSet 函数
⊙ GetEnumName / GetEnumValue / GetEnumNameValue 函数
示例1:一键设置所有控件的CustomHint属性(delphi 2010 +)
procedure TForm1.M_SetCustomHint; var i:integer; begin for i := 0 to self.ComponentCount - 1 do begin if IsPublishedProp(self.Components[i],'CustomHint') then if GetObjectProp(self.Components[i],'CustomHint')=nil then begin SetPropValue(self.Components[i],'ShowHint',true); SetObjectProp(self.Components[i],'CustomHint',BalloonHint1); end; end; end;
示例2:一键设置所有控件的输入(delphi 7+)
procedure TForm1..setImeName(MyCtrl:TCustomControl); var i:Integer; begin for i:=0 to MyCtrl.ControlCount-1 do Begin if IsPublishedProp(MyCtrl.Controls[i],'ImeMode') then begin if (TWinControl(MyCtrl.Controls[i]).Enabled) and GetPropValue(MyCtrl.Controls[i],'ImeMode',false)<>imclose then begin SetPropValue(MyCtrl.Controls[i],'ImeMode',imopen); SetPropValue(MyCtrl.Controls[i],'ImeName',Data_main.User_IME); end end; End; end;
使用RTTI方法需要引用TypInfo单元,更多RTTI的应用,请下载
RTTI深度应用
部分演示代码
相关文章推荐
- PHP从零单排(十七)主要图像处理函数及图像基础示例
- C#回调函数应用示例,形象比喻方法助理解 (转载)
- asterisk主要的应用函数
- python基础教程共60课-第22课函数应用示例
- JavaScript eval() 函数介绍及应用示例
- js 时间函数应用加、减、比较、格式转换的示例代码
- avascript中的自执行匿名函数应用示例
- Oracle DECODE 函数应用示例
- go语言函数参数与返回值示例,数组的简单应用
- avascript中的自执行匿名函数应用示例
- IOCP以及扩展Windows socket函数应用示例
- GIT的API主要应用示例
- Oracle函数to_char应用示例
- 【Shell】函数应用简单示例
- printf()函数及其应用示例
- Split 函数应用示例 ( VBScript版本 )
- 函数BAPI_MATERIAL_SAVEDATA基本应用示例
- JavaScript eval() 函数介绍及应用示例
- matlab中griddata函数应用示例
- 简单画图板示例(虚函数应用示例)