Component positioning to the form/Tpanel center lazarus / 10-Designer ---------------------------------------------------------------------- christensen · 2011-08-28 17:36 How to position a component(ex. Timage) to the form/Tpanel center and keep at the center after resizing the form? ---------------------------------------------------------------------- Blaazen · 2011-08-28 18:23 TImage has property "Center". When I set it to "True" Image keeps centered when I resize form. In design time, you can create initial centered position by right- click on TImage, select Align ..." and set radiobuttons "Center in Window" for both Vertical and Horizontal. ---------------------------------------------------------------------- christensen · 2011-08-28 19:03 the center property work, only i haven't set false the Anchors properties. thanks ---------------------------------------------------------------------- christensen · 2011-08-30 05:38 OK, now i have another problem. I have 2 forms: Mainform and Childform.(sort of MDI) The Childform open in the Tpanel of the main form. On the Childform I have a few components: Tedit,DateEdit,Tcombobox,Tlabel,Tmemo. How can i setup them to keep there position as best when i resize the Mainform? I've try to keep at the form center but it looks ugly, especial when the Mainform is resized. The same i've try to align to left,right but still ugly. ---------------------------------------------------------------------- avra · 2011-08-30 06:45 Code: [Select]function CenterInParent(Place,NumberOfPlaces,ObjectWidth ,ParentWidth,CropPercent: Integer): Integer;   {returns formated centered position of an object relative to parent.   Place          - P order number of an object beeing centered   NumberOfPlaces - NOP total number of places available for object beeing centered   ObjectWidth    - OW width of an object beeing centered   ParentWidth    - PW width of an parent   CropPercent    - CP percentage of safe margin on both sides which we want to omit from calculation   +-----------------------------------------------------+   |                                                     |   |        +--------+       +---+      +--------+       |   |        |        |       |   |      |        |       |   |        +--------+       +---+      +--------+       |   |     |              |             |            |     |   +-----------------------------------------------------+   |     |<---------------------A----------------->|     |   |<-C->|<------B----->|<-----B----->|<-----B---->|<-C->|   |                    |<-D>|   |<----------E------------>|   A = PW-C   B = A/NOP  C=(CP*PW)/100  D = (B-OW)/2   E = C+(P-1)*B+D } var   A, B, C, D: Integer; begin   C := Trunc((CropPercent*ParentWidth)/100);   A := ParentWidth - C;   B := Trunc(A/NumberOfPlaces);   D := Trunc((B-ObjectWidth)/2);   Result := C+(Place-1)*B+D; end;