Delphi calls the master’s method (to build a procedure of object)

Delphi can call the method of the parent class through inherited, but it does not provide a method to directly call the parent class of the parent class (the grandfather class). The implementation is as follows through a flexible method:

Assuming the parent class It is TFather, the grandpa class TGrand, calls the Write method of the grandpa class:

1
2
3
4
5
6
7
8
9

type
TWriteProc= procedure of< /code> Object ;
var
WriteProc:TWriteProc ;
....

code>

TMethod(WriteProc).Code:[emailprotected] . Write ;
TMethod(WriteProc).Data:=Self;
< code class="delphi spaces"> WriteProc;

  https://www.cnblogs.com/hezihang/p/4139656.html

1
2
3
4
5
6
7
8
9
type
TWriteProc= procedure of code> Object ;
var
WriteProc:TWriteProc; < /div>

....
TMethod(WriteProc).Code:[email protected] . Write ;
TMethod(WriteProc).Data:=Self;
WriteProc;

1
2
3
4
5
6
7
8
9
type
TWriteProc= procedure of Object ; < /div>

var
WriteProc:TWriteProc;
....
TMethod(WriteProc).Code:[emailprotected] . Write ;
< code class="delphi spaces"> TMethod(WriteProc).Data:=Self;
WriteProc;

1
2
3
4
5
6
7 < /div>

8
9
type
TWriteProc= procedure of Object ;
var
WriteProc:TWriteProc;
....
< code class="delphi plain">TMethod(WriteProc).Code:[email protected] . Write ;
TMethod(WriteProc).Data:=Self;
WriteProc;

1

2< /p>

3

4

5

6

7

8

9

type
TWriteProc= procedure of Object ;
var
WriteProc:TWriteProc;
.. ..
TMethod(WriteProc).Code: [email protected] . Write ;
TMethod(WriteProc).Data:=Self;
WriteProc;

type

< /code> TWriteProc= procedure of Object ;

var

< p> WriteProc:TWriteProc;

....

TMethod(WriteProc).Code:[ email protected] . Write ;

TMethod(WriteProc).Data:=Self;

WriteProc;

Leave a Comment

Your email address will not be published.