[SOLVED]How to get real size after AutoSize lazarus / 31-LCL ---------------------------------------------------------------------- tomitomy · 2017-10-27 14:50 Hi, everybody. I was adjusting my program GUI and I encountered a problem, When the size of CheckBox changed automatically, I want to get the real size. What should I do? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormCreate(Sender: TObject);begin  CheckBox1.AutoSize := True;  CheckBox1.Caption := 'TTTTTTTTTTTTTTTest';  // CheckBox1.Width is a wrong value  Edit1.Left := CheckBox1.Left + CheckBox1.Width;end; ---------------------------------------------------------------------- wp · 2017-10-27 15:04 Read the excellent wiki article about Autosizing and Layout. At designtime use the anchor editor to link the left side of one control to the right side of the previous one etc. This is an amazing tool! You'll never calculate control positions like you did in the previous post. ---------------------------------------------------------------------- tomitomy · 2017-10-27 15:13 Quote from: wp on October 27, 2017, 05:04:54 pmRead the excellent wiki article about Autosizing and Layout. At designtime use the anchor editor to link the left side of one control to the right side of the previous one etc. This is an amazing tool! You'll never calculate control positions like you did in the previous post. Thank you, wp. I'll read it seriously. Thank you very much! ---------------------------------------------------------------------- jamie · 2017-10-28 01:08 To calculate the real-estate the text will use you can use the var  aSize :TSize; begin aSize := Canvas.TextExtent('Your Text'); Clientwidth := aSize.cx; End;  This will return a TSize and  that has members CX, and CY, they report the width and height of canvas needed. ---------------------------------------------------------------------- tomitomy · 2017-10-28 02:22 Quote from: jamie on October 28, 2017, 03:08:35 amTo calculate the real-estate the text will use you can use the var  aSize :TSize; begin aSize := Canvas.TextExtent('Your Text'); Clientwidth := aSize.cx; End;  This will return a TSize and  that has members CX, and CY, they report the width and height of canvas needed. Thank you, jamie, but I don't konw how to get the CheckBox's  Canvas, Would it be a problem to get the CheckBox's  text size using the form's Canvas? ---------------------------------------------------------------------- jamie · 2017-10-29 00:52 Use the parent of the checkbox..  aTSizeVariable := (CheckBox1.Parent as Tform).Canvas.TextExtent('mmm');  ATsizevariable.cx ,,, cy etc. ---------------------------------------------------------------------- tomitomy · 2017-10-29 02:13 Thank you, jamie, I have learnt it. ---------------------------------------------------------------------- tomitomy · 2017-10-29 02:18 Quote from: wp on October 27, 2017, 05:04:54 pmRead the excellent wiki article about Autosizing and Layout. At designtime use the anchor editor to link the left side of one control to the right side of the previous one etc. This is an amazing tool! You'll never calculate control positions like you did in the previous post. Thank you, wp, "Anchors" is very powerful!