Главная страница | назад





Article #15380: How do I center a form on its parent?

 Question and Answer Database

FAQ380C.txt   How do I center a form on its parent?
Category   :VCL
Platform    :All
Product    :C++Builder  1.x

Question:
How do I center a form relative to its parent?

Answer:
The following code will do it:

if(Parent) {
   ChildForm->Left=ParentForm->Left+
       ((ParentForm->Width-ChildForm->Width)/2);
   ChildForm->Top=ParentForm->Top+
       ((ParentForm->Height-CHildForm->Height)/2);
   if((ChildForm->Left+ChildForm->Width)>Screen->Width)
        ChildForm->Left=Screen->Width-ChildForm->Width;
   if((ChildForm->Top+ChildForm->Height)>Screen->Height)
        ChildForm->Top=Screen->Height-ChildForm->Height;
   }


7/2/98 10:32:32 AM
 

Last Modified: 01-SEP-99