Every once in a while you want to have a Delphi Watch
of a field inside an object (say an object of type TContext
), except that the field has no value yet, but eventually will point to another object (say an object of type TUser
).
However, the original object will go out of scope, so you need to employ a few tricks.
First of all, you get the address of that field:
@(Context().FCurrentUser) = $7EF6F624
Then you watch the content of that field:
TUser(PPointer($7EF6F624)^),r = nil
To get to this trick, you have to remember:
- The contents of address
$7EF6F624
is pointer (at firstnil
) to aTUser
. - You get to the contents of the address
$7EF6F624
by usingPPointer($7EF6F624)^
. - Then you cast it to the object you want with the
TUser(...)
cast.
–jeroen