Centering a Tframe within a TTabSheet;-Collection of common programming errors

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’ve assigned the parent before doing so.

If the page control can be re-sized at runtime, add a call to this function from the tabsheet’s OnResize event. Or, as NGLN points out simply set the control’s Anchors to [] and the VCL framework will take care off centring the control when its parent is resized.