[Lazarus] TImage - Getting image properties in 'canvas space'
Sven Barth
pascaldragon at googlemail.com
Wed Apr 18 09:12:03 CEST 2012
Am 17.04.2012 22:32, schrieb Reimar Grabowski:
> 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?
> IMHO to access DestRec TMyHackImage must be derived from TCustomImage and in that case the cast won't work.
Yes, sorry. I've now tested the following example which is different
from your original problem, but it illustrates the hacky mechanism:
=== source begin ===
program hacktest;
{$mode objfpc}
uses
Classes;
type
TMyStrings = class(TStringList)
end;
var
s: TStringList;
begin
s := TStringList.Create;
s.Add('Test');
Writeln(TMyStrings(s).GetCount); // "GetCount" is protected in
"TStringList"
end.
=== source end ===
Regards,
Sven
More information about the Lazarus
mailing list