![]() |
|
#1
|
|||
|
|||
|
If you know C++ you know that a function prototyped in the host class preceded by the keyword 'friend' will have access to all the private and protected members of the host class.
Is there an equivalent cheat in Delphi? Or another way to accomplish this sort of thing? I have looked but havent found anything yet. Thanks, and yes I know 'friends are bad' as my C++ prof used to say ![]() Seth (new to Delphi) |
|
#2
|
|||
|
|||
|
Delphi lacks some C++ features. neither "Friends", nor Operator overloading are supported.
|
|
#3
|
|||
|
|||
|
One of the quirks of Delphi is that classes in the same unit can access protected and private methods and variables. Borland does this a lot in their VCL component libraries. I have declared a class in an existing VCL to access private parts but I do not recommend this. Every time you upgrade you Delphi, you need to upgrade you class on the new VCL. I would hope that Borland would add a “Friend” identifier, but I don’t think they will. Also, you might try using to old “Hack” trick. Declare a class in you unit derived from the class you want to get the protected ???? from :
THackClass = class(DBGrid); In your program cast you "Hack Class" like this: with THackDBGrid(DBGrid1).Canvas do ……….. end; This will get you the protected canvas object. I don’t know if it will work for private parts. There are some good examples of this out there if you want more information.. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|