[Lazarus] TImage - Getting image properties in 'canvas space'

Hans-Peter Diettrich DrDiettrich1 at aol.com
Wed Apr 18 09:58:56 CEST 2012


Reimar Grabowski schrieb:
> On Tue, 17 Apr 2012 22:19:45 +0200
> Sven Barth <pascaldragon at googlemail.com> wrote:
> 
>> type
>>    TMyHackImage = class(TImage)
>>    public
>>      function DestRect: TRect;
>>    end;
>>
>> var
>>    MyImage: TImage;
>>    r: TRect;
>> begin
>>    // let's suppose that MyImage contains a TImage instance
>>    r := TMyHackImage(MyImage).DestRect
>> end;
> How should that work?
> What does the DestRec function look like?

You're right, above code should not work. The DestRect function has to 
be omitted from above declaration, so that the DestRect of the base 
class is used.

The elevation of visibility only works for *properties*, i.e.
   public
     property DestRect;
should work. But often (depending on the compiler) the mere declaration 
of an empty derived class allows to access protected members of the base 
class.

DoDi





More information about the Lazarus mailing list