中国开发网: 论坛: 程序员情感CBD: 贴子 137436
haitao
我的脚本delphi也快成功了
只是为了导入delphi中的一个类(使得脚本也能识别、运行这个类),需要不少代码,干脆写了一个代码生成工具:
它的存储内容为:(这是导入TCheckListBox的例子)
{Class2PS
ClassName=TCheckListBox
SubClassCount=1
SubClass0=TCustomListBox
FieldCount=8
1.0=AllowGrayed
1.1=Boolean
1.2=
1.3=
1.4=rw
2.0=Checked
2.1=Boolean
2.2=Integer
2.3=
2.4=rw
3.0=Flat
3.1=Boolean
3.2=
3.3=
3.4=rw
4.0=ItemEnabled
4.1=Boolean
4.2=Integer
4.3=
4.4=rw
5.0=Header
5.1=Boolean
5.2=Integer
5.3=
5.4=rw
6.0=HeaderBackgroundColor
6.1=TColor
6.2=
6.3=
6.4=rw
7.0=HeaderColor
7.1=TColor
7.2=
7.3=
7.4=rw
8.0=State
8.1=TCheckBoxState
8.2=Integer
8.3=
8.4=rw
Class2PS}

它生成的代码为:
Procedure TCheckListBox_AllowGrayed_R(Self: TCheckListBox; Var T: Boolean); Begin T := Self.AllowGrayed; End;
Procedure TCheckListBox_AllowGrayed_W(Self: TCheckListBox; T: Boolean); Begin Self.AllowGrayed := T; End;
Procedure TCheckListBox_Checked_R(Self: TCheckListBox; Var T: Boolean; t1:Integer); Begin T := Self.Checked[t1]; End;
Procedure TCheckListBox_Checked_W(Self: TCheckListBox; T: Boolean; t1:Integer); Begin Self.Checked[t1] := T; End;
Procedure TCheckListBox_Flat_R(Self: TCheckListBox; Var T: Boolean); Begin T := Self.Flat; End;
Procedure TCheckListBox_Flat_W(Self: TCheckListBox; T: Boolean); Begin Self.Flat := T; End;
Procedure TCheckListBox_ItemEnabled_R(Self: TCheckListBox; Var T: Boolean; t1:Integer); Begin T := Self.ItemEnabled[t1]; End;
Procedure TCheckListBox_ItemEnabled_W(Self: TCheckListBox; T: Boolean; t1:Integer); Begin Self.ItemEnabled[t1] := T; End;
Procedure TCheckListBox_Header_R(Self: TCheckListBox; Var T: Boolean; t1:Integer); Begin T := Self.Header[t1]; End;
Procedure TCheckListBox_Header_W(Self: TCheckListBox; T: Boolean; t1:Integer); Begin Self.Header[t1] := T; End;
Procedure TCheckListBox_HeaderBackgroundColor_R(Self: TCheckListBox; Var T: TColor); Begin T := Self.HeaderBackgroundColor; End;
Procedure TCheckListBox_HeaderBackgroundColor_W(Self: TCheckListBox; T: TColor); Begin Self.HeaderBackgroundColor := T; End;
Procedure TCheckListBox_HeaderColor_R(Self: TCheckListBox; Var T: TColor); Begin T := Self.HeaderColor; End;
Procedure TCheckListBox_HeaderColor_W(Self: TCheckListBox; T: TColor); Begin Self.HeaderColor := T; End;
Procedure TCheckListBox_State_R(Self: TCheckListBox; Var T: TCheckBoxState; t1:Integer); Begin T := Self.State[t1]; End;
Procedure TCheckListBox_State_W(Self: TCheckListBox; T: TCheckBoxState; t1:Integer); Begin Self.State[t1] := T; End;
//For Exec:TCheckListBox
Procedure RIRegister_TCheckListBox(Cl: TPSRuntimeClassImporter);
Begin
Cl.Add(TCustomListBox);
With Cl.Add(TCheckListBox) Do
Begin
RegisterPropertyHelper(@TCheckListBox_AllowGrayed_R, @TCheckListBox_AllowGrayed_W, 'AllowGrayed');
RegisterPropertyHelper(@TCheckListBox_Checked_R, @TCheckListBox_Checked_W, 'Checked');
RegisterPropertyHelper(@TCheckListBox_Flat_R, @TCheckListBox_Flat_W, 'Flat');
RegisterPropertyHelper(@TCheckListBox_ItemEnabled_R, @TCheckListBox_ItemEnabled_W, 'ItemEnabled');
RegisterPropertyHelper(@TCheckListBox_Header_R, @TCheckListBox_Header_W, 'Header');
RegisterPropertyHelper(@TCheckListBox_HeaderBackgroundColor_R, @TCheckListBox_HeaderBackgroundColor_W, 'HeaderBackgroundColor');
RegisterPropertyHelper(@TCheckListBox_HeaderColor_R, @TCheckListBox_HeaderColor_W, 'HeaderColor');
RegisterPropertyHelper(@TCheckListBox_State_R, @TCheckListBox_State_W, 'State');
End;
End;
//For Compile:TCheckListBox
Procedure SIRegister_TCheckListBox(Cl: TPSPascalCompiler);
Begin
With Cl.AddClassN(cl.FindClass('TCustomListBox'),'TCheckListBox') Do
Begin
RegisterProperty('AllowGrayed', 'Boolean', iptrw);
RegisterProperty('Checked', 'Boolean Integer', iptrw);
RegisterProperty('Flat', 'Boolean', iptrw);
RegisterProperty('ItemEnabled', 'Boolean Integer', iptrw);
RegisterProperty('Header', 'Boolean Integer', iptrw);
RegisterProperty('HeaderBackgroundColor', 'TColor', iptrw);
RegisterProperty('HeaderColor', 'TColor', iptrw);
RegisterProperty('State', 'TCheckBoxState Integer', iptrw);
End;
End;
我的blog:http://szhaitao.blog.hexun.com & http://www.hoolee.com/user/haitao
--以上均为泛泛之谈--
不尽牛人滚滚来,无边硬伤纷纷现 人在江湖(出来的),哪能不挨刀(总归是要的)
网络对话,歧义纷生;你以为明白了对方的话,其实呢?

您所在的IP暂时不能使用低版本的QQ,请到:http://im.qq.com/下载安装最新版的QQ,感谢您对QQ的支持和使用

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录