tpaxscripter_routines.htm

来自「Delphi脚本控件」· HTM 代码 · 共 610 行 · 第 1/2 页

HTM
610
字号


<a name="RegisterMethod"><h3>RegisterMethod</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Registeres a method of Delphi class.
<pre>
<font color="blue"><b>procedure</b></font> RegisterMethod(PClass: TClass; <font color="blue"><b>const</b></font> Header: <font color="blue"><b>String</b></font>; Address: Pointer);
</pre>
<H4>
Arguments
</H4>
<blockquote>
<i>PClass</i>
<blockquote>
A Delphi class.
</blockquote>
</blockquote>
<blockquote>
<i>Header</i>
<blockquote>
<font color="black"><i>Header</i></font> of method.
</blockquote>
</blockquote>
<blockquote>
<i>Address</i>
<blockquote>
<font color="black"><i>Address</i></font> of method.
</blockquote>
</blockquote>
<p>
<H4>
Example
</H4>
<pre>
initialization
..........................
RegisterMethod(TStringList, <font color="Red">'procedure Clear; override;'</font>, @TStringList.Clear);
</pre>
</p>
<p>
The method becomes available for all TPaxScripter instances.
</p>
<H4>
See Also
</H4>
<blockquote>
<ul>
<li><a href="#RegisterBCBMethod">RegisterBCBMethod</a></li>
</ul>
</blockquote>
</blockquote>
<a name="RegisterBCBMethod"><h3>RegisterBCBMethod</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Registeres method of a C++ Builder defined class.
<pre>
<font color="blue"><b>procedure</b></font> RegisterBCBMethod(PClass: TClass; <font color="blue"><b>const</b></font> Header: <font color="blue"><b>String</b></font>; Address: Pointer);
</pre>
<p>
<H4>
Example
</H4>
<pre>
void __fastcall TForm1::Foo()
{
ShowMessage(<font color="Red">"Foo"</font>);
}

void __fastcall TForm1::FormCreate(TObject *Sender)
{
 void ( __closure __fastcall *pp)();
 pp = Foo;

 RegisterClassType(__classid(TForm1), -1);
 RegisterBCBMethod(__classid(TForm1), <font color="Red">"procedure Foo;"</font>, &pp);
}
</pre>
</p>
<H4>
See Also
</H4>
<blockquote>
<ul>
<li><a href="#RegisterMethod">RegisterMethod</a></li>
</ul>
</blockquote>
</blockquote>
<a name="RegisterNamespace"><h3>RegisterNamespace</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Registeres namespace.
<pre>
<font color="blue"><b>function</b></font> RegisterNamespace(<font color="blue"><b>const</b></font> Name: <font color="blue"><b>String</b></font>; Owner: Integer = -1): Integer;
</pre>
<H4>
Arguments
</H4>
<blockquote>
<i>Name</i>
<blockquote>
<font color="black"><i>Name</i></font> of the namespace.
</blockquote>
</blockquote>
<blockquote>
<i>Owner</i>
<blockquote>
Determines handle of namespace which contains given namespace.
</blockquote>
</blockquote>
<p>
Returns handle of the namespace.
<H4>
Example
</H4>
<pre>
initialization
................................

H := RegisterNamespace(<font color="Red">'MyNamespace'</font>);
H := RegisterNamespace(<font color="Red">'MyNestedNamespace'</font>, H);
</pre>
</p>
<p>
The namespace becomes available for all TPaxScripter instances.
</p>
</blockquote>
<a name="RegisterProperty"><h3>RegisterProperty</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Registeres a property of Delphi class.
<pre>
<font color="blue"><b>procedure</b></font> RegisterProperty(PClass: TClass; <font color="blue"><b>const</b></font> PropDef: <font color="blue"><b>String</b></font>);
</pre>
<H4>
Arguments
</H4>
<blockquote>
<i>PClass</i>
<blockquote>
A Delphi class.
</blockquote>
</blockquote>
<blockquote>
<i>PropDef</i>
<blockquote>
A property definition.
</blockquote>
</blockquote>
<p>
<H4>
Example
</H4>
<pre>
initialization
..........................................

RegisterMethod(TList, <font color="Red">'function Get(Index: Integer): Pointer;'</font>, @TList_Get, Fake);
RegisterMethod(TList, <font color="Red">'procedure Put(Index: Integer; Item: Pointer);'</font>, @TList_Put, Fake);
RegisterProperty(TList, <font color="Red">'property Items[Index: Integer]: Pointer read Get write Put; default;'</font>);
</pre>
</p>
<p>
The property becomes available for all TPaxScripter instances.
</p>
</blockquote>
<a name="RegisterRecordType"><h3>RegisterRecordType</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Allows you to register a record type defined in your Delphi application.
<pre>
<font color="blue"><b>function</b></font> RegisterRecordType(<font color="blue"><b>const</b></font> TypeName: <font color="blue"><b>String</b></font>;
                            Size: Integer;
                            OwnerIndex: Integer = -1): Integer;
</pre>
<H4>
Arguments
</H4>
<blockquote>
<i>TypeName</i>
<blockquote>
Name of the type
</blockquote>
</blockquote>
<blockquote>
<i>Size</i>
<blockquote>
<font color="black"><i>Size</i></font> of the type
</blockquote>
</blockquote>
<blockquote>
<i>OwnerIndex</i>
<blockquote>
Index of namespace which contains the record type.
</blockquote>
</blockquote>
<p>
<H4>
Example
</H4>
<pre>
<A HREF="tps_demo_records.htm">Click here</A>
</pre>
</p>
</blockquote>
<a name="RegisterRecordField"><h3>RegisterRecordField</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Allows you to register a field of the record type.
<pre>
<font color="blue"><b>procedure</b></font> RegisterRecordField(OwnerIndex: Integer; <font color="blue"><b>const</b></font> FieldName, FieldType: <font color="blue"><b>String</b></font>;
                              Offset: Integer): Integer;
</pre>
<H4>
Arguments
</H4>
<blockquote>
<i>OwnerIndex</i>
<blockquote>
Index of the record type.
</blockquote>
</blockquote>
<blockquote>
<i>FieldName</i>
<blockquote>
Name of field
</blockquote>
</blockquote>
<blockquote>
<i>FieldType</i>
<blockquote>
Type of field
</blockquote>
</blockquote>
<blockquote>
<i>Offset</i>
<blockquote>
<font color="black"><i>Offset</i></font> of field.
</blockquote>
</blockquote>
<p>
<H4>
Example
</H4>
<pre>
<A HREF="tps_demo_records.htm">Click here</A>.
</pre>
</p>
</blockquote>
<a name="RegisterRoutine"><h3>RegisterRoutine</h3></a>
<!-------------------------------------------------------------------->
<blockquote>
Registeres a global procedure or function.
<pre>
<font color="blue"><b>procedure</b></font> RegisterRoutine(<font color="blue"><b>const</b></font> Header: <font color="blue"><b>String</b></font>; Address: Pointer; Owner: Integer = -1);
</pre>
<H4>
Arguments
</H4>
<blockquote>
<i>Header</i>
<blockquote>
<font color="black"><i>Header</i></font> of the procedure or function.
</blockquote>
</blockquote>
<blockquote>
<i>Owner</i>
<blockquote>
Determines handle of namespace which contains given procedure or function.
</blockquote>
</blockquote>
<p>
<H4>
Example
</H4>
<pre>
Delphi:

RegisterRoutine(<font color="Red">'function GetStrTime: String;'</font>, @GetStrTime, -1);

C++ Builder:

AnsiString GetStrTime() {
  return DateTimeToStr(Now());
}

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  RegisterRoutine(<font color="Red">"function GetStrTime: String; cdecl;"</font>, GetStrTime, -1);
}
</pre>
</p>
<p>
The function becomes available for all TPaxScripter instances.
</p>
</blockquote>
<p>
<HR>
<font size = 1 color ="gray">
Copyright &copy; 1999-2005
VIRT Laboratory. All rights reserved.
</font>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?