Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-07

Owner of a TCanvas

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Flávio Etrusco
to Xiangrong Fang
Xiangrong Fang wrote 14 lines
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.freepascal.org/pipermail/lazarus/attachments/20150727/8e51c390/attachment.html>

Reply by email

Howard Page-Clark
to Xiangrong Fang: Can I somehow get the object which owns a Canvas? e.g.: function GetCanvasOwner(ACanvas:…
Xiangrong Fang wrote 9 lines
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);

A TCanvas does not have a built-in Owner property. It descends from TPersistent, but not from TComponent, the class that introduces Owner and ownership.

---
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Reply by email