In this example:
Preparation: after creating a new project, add a panel and four checkboxes on the form. Double-click them to generate default events, and select all Code And overwrite the following code.
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls, extctrls; Type tform1 = Class (tform) Panel1: tpanel; checkbox1: tcheckbox; checkbox2: tcheckbox; checkbox3: tcheckbox; checkbox4: tcheckbox; Procedure destroy (Sender: tobject); Procedure checkbox2click (Sender: tobject ); procedure checkbox3click (Sender: tobject); Procedure checkbox4click (Sender: tobject); Procedure panel1click (Sender: tobject); Procedure setanchor (Sender: tobject; AK: tanchors ); {custom process} end; var form1: tform1; implementation {$ R *. DFM} {make a public process for the checkbox} procedure tform1.setanchor (Sender: tobject; AK: tanchors); begin with Panel1 do if tcheckbox (sender ). checked then anchors: = anchors + AK else anchors: = anchors-ak; end; {initialization} procedure tform1.formcreate (Sender: tobject); begin panel1.anchors: = [akleft, aktop]; {This is the default value} checkbox1.checked: = true; checkbox2.checked: = true; checkbox1.caption: = 'akleft'; checkbox2.caption: = 'aktop '; checkbox3.caption: = 'akright'; checkbox4.caption: = 'akbottom '; panel1.parentbackground: = false; panel1.color: = clyellow; end; {change form size} procedure tform1.panel1click (Sender: tobject); const S1 = 'click to enlarge form '; s2 = 'click to narrow down the form'; begin if panel1.caption = S2 then begin panel1.caption: = S1; width: = round (width/1.5); Height: = round (height/1.5 ); end else begin panel1.caption: = S2; width: = round (width * 1.5); Height: = round (height * 1.5); end; Procedure tform1.checkbox1click (Sender: tobject ); begin setanchor (sender, [akleft]); end; Procedure tform1.checkbox2click (Sender: tobject); begin setanchor (sender, [aktop]); end; Procedure submit (Sender: tobject ); begin setanchor (sender, [akright]); end; Procedure tform1.checkbox4click (Sender: tobject); begin setanchor (sender, [akbottom]); end.