{"id":4274,"date":"2014-03-30T09:37:45","date_gmt":"2014-03-30T09:37:45","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/centering-a-tframe-within-a-ttabsheet-collection-of-common-programming-errors\/"},"modified":"2014-03-30T09:37:45","modified_gmt":"2014-03-30T09:37:45","slug":"centering-a-tframe-within-a-ttabsheet-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/centering-a-tframe-within-a-ttabsheet-collection-of-common-programming-errors\/","title":{"rendered":"Centering a Tframe within a TTabSheet;-Collection of common programming errors"},"content":{"rendered":"<p>To centre a control in its parent do this:<\/p>\n<pre><code>procedure CentreControl(Control: TControl);\nbegin\n  Control.Left := (Control.Parent.ClientWidth-Control.Width) div 2;\n  Control.Top := (Control.Parent.ClientHeight-Control.Height) div 2;\nend;\n<\/code><\/pre>\n<p>Call this function, passing the frame. Obviously you need to wait until you&#8217;ve assigned the parent before doing so.<\/p>\n<p>If the page control can be re-sized at runtime, add a call to this function from the tabsheet&#8217;s OnResize event. Or, as NGLN points out simply set the control&#8217;s <code>Anchors<\/code> to <code>[]<\/code> and the VCL framework will take care off centring the control when its parent is resized.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To centre a control in its parent do this: procedure CentreControl(Control: TControl); begin Control.Left := (Control.Parent.ClientWidth-Control.Width) div 2; Control.Top := (Control.Parent.ClientHeight-Control.Height) div 2; end; Call this function, passing the frame. Obviously you need to wait until you&#8217;ve assigned the parent before doing so. If the page control can be re-sized at runtime, add a call [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4274","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4274"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4274\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}