<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 27, 2015 at 6:31 AM, Xiangrong Fang <span dir="ltr"><<a href="mailto:xrfang@gmail.com" target="_blank">xrfang@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:monospace,monospace;font-size:large">Hi There,</div><div style="font-family:monospace,monospace;font-size:large"><br></div><div style="font-family:monospace,monospace;font-size:large">Can I somehow get the object which owns a Canvas? e.g.:</div><div style="font-family:monospace,monospace;font-size:large"><br></div><div style="font-family:monospace,monospace;font-size:large">function GetCanvasOwner(ACanvas: TCanvas): TObject;</div><div style="font-family:monospace,monospace;font-size:large">begin</div><div style="font-family:monospace,monospace;font-size:large">   Result := ACanvas<font color="#ff0000">.Owner;</font></div><div style="font-family:monospace,monospace;font-size:large">end;</div><div style="font-family:monospace,monospace;font-size:large">pb := TPaintBox(GetCanvasOwner(pb.Canvas);<br></div><div style="font-family:monospace,monospace;font-size:large"><br></div><div style="font-family:monospace,monospace;font-size:large">Thanks!</div><div style="font-family:monospace,monospace;font-size:large">Xiangrong</div><div style="font-family:monospace,monospace;font-size:large"><br></div></div></blockquote><div><br></div><div>You can if the canvas is a TControlCanvas. Luckly TGraphicControl.Canvas is a TControlCanvas, thus one can do e.g.:<br><br></div><div><div style="font-family:monospace,monospace;font-size:large">function GetCanvasOwner(ACanvas: TCanvas): TControl;</div><div style="font-family:monospace,monospace;font-size:large">begin</div><div style="font-family:monospace,monospace;font-size:large">   Result := (ACanvas<font color="#ff0000"> as TControlCanvas).Control;</font></div><div style="font-family:monospace,monospace;font-size:large">end;<br><br></div><div style="font-family:monospace,monospace;font-size:large">Regards,<br></div><div style="font-family:monospace,monospace;font-size:large">Flávio<br></div></div></div></div></div>