[Lazarus] Owner of a TCanvas

Flávio Etrusco flavio.etrusco at gmail.com
Mon Jul 27 13:29:29 CEST 2015


On Mon, Jul 27, 2015 at 6:31 AM, Xiangrong Fang <xrfang at gmail.com> wrote:

> Hi There,
>
> Can I somehow get the object which owns a Canvas? e.g.:
>
> function GetCanvasOwner(ACanvas: TCanvas): TObject;
> begin
>    Result := ACanvas.Owner;
> end;
> pb := TPaintBox(GetCanvasOwner(pb.Canvas);
>
> Thanks!
> Xiangrong
>
>
You can if the canvas is a TControlCanvas. Luckly TGraphicControl.Canvas is
a TControlCanvas, thus one can do e.g.:

function GetCanvasOwner(ACanvas: TCanvas): TControl;
begin
   Result := (ACanvas as TControlCanvas).Control;
end;

Regards,
Flávio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20150727/8e51c390/attachment-0003.html>


More information about the Lazarus mailing list