Matvey
asked on
Overriding Private methods
I have to override a private method :
TTrackBar
Priate
procedure SetPosition(Value: Integer) of TTrackBar
How ?
TTrackBar
Priate
procedure SetPosition(Value: Integer) of TTrackBar
How ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you ra_tim, but what I need is to add some code to a private method after I call the Inherited method (or get the method do whatever it has to do any other way).
But anyway, I can copy the source code of that private method, rewrite it in my control and do the thing you say.
But anyway, I can copy the source code of that private method, rewrite it in my control and do the thing you say.
To access a local variable is simple:
// TClass1 contains a private variable
TClass1 = class
private
FSecret : integer;
end;
// TClass2 is a has the same structure (and byte organisation)
// as TClass1 only that members are public.
TClass2 = class
public
FSecret : integer;
end;
procedure Hack;
var a : TClass1;
begin
a := TClass1.Create;
TClass2(a).FSecret := 100;
// This cast makes it possible to access a private variable
end;