Board index » delphi » Centering a form

Centering a form

Is there a way to center a form on the screen at any resolution?

Thanks (in advance).

 

Re:Centering a form


Quote
Bard dZen wrote:

> Is there a way to center a form on the screen at any resolution?

> Thanks (in advance).

Set the Position property to poScreenCenter

Matthew
--

==================================================================
Matthew McDermott
McDermott Enterprises
matt...@valleynet.com
My Web Page: http://www.valleynet.com/~matthew
------------------------------------------------------------------
Director of Information Services & Adjunct Professor - Mathematics
The American College of Prehospital Medicine: http://www.acpm.edu/
==================================================================

Re:Centering a form


Quote
Bard dZen (bard-d...@utech.net) wrote:

: Is there a way to center a form on the screen at any resolution?

: Thanks (in advance).

There is a property - Position - in form. You would choose poScreenCenter.

Try it!!

------------------
Lawrence Lam

Re:Centering a form


Quote
Bard dZen wrote:

> Is there a way to center a form on the screen at any resolution?

> Thanks (in advance).

        Yes.
        Look at the Position Propery for the Form.

        brant
        ...

Re:Centering a form


Quote
Bard dZen wrote:

> Is there a way to center a form on the screen at any resolution?

> Thanks (in advance).

Bard,

If you want to center a form other than when it's being created, then this should do it:

procedure TForm1.Button1Click(Sender: TObject); begin
Form1.Top := ((Screen.Height div 2) - (Form1.Height div 2));
Form1.Left := ((Screen.Width div 2) - (Form1.Width div 2)); end;

To center when it's being created it's much easier to set the forms position property
to poScreenCenter.

Re:Centering a form


In article <31C43B2A.1...@futureone.com>, gary...@futureone.com says...

Quote

>Bard dZen wrote:

>> Is there a way to center a form on the screen at any resolution?

>> Thanks (in advance).

>Bard,

>If you want to center a form other than when it's being created, then
this should do it:

>procedure TForm1.Button1Click(Sender: TObject); begin
>Form1.Top := ((Screen.Height div 2) - (Form1.Height div 2));
>Form1.Left := ((Screen.Width div 2) - (Form1.Width div 2)); end;

Unfortunately it's not that simple if you take into account the Win '95
toolbar.

Re:Centering a form


In <Edina1996Jun26.015010.19...@news3.idirect.com.compulink.com>, vit...@io.org (Vitaly Livshits) writes:

Quote
>In article <31C43B2A.1...@futureone.com>, gary...@futureone.com says...

>>Bard dZen wrote:

>>> Is there a way to center a form on the screen at any resolution?

>>> Thanks (in advance).

>>Bard,

>>If you want to center a form other than when it's being created, then
>this should do it:

>>procedure TForm1.Button1Click(Sender: TObject); begin
>>Form1.Top := ((Screen.Height div 2) - (Form1.Height div 2));
>>Form1.Left := ((Screen.Width div 2) - (Form1.Width div 2)); end;

>Unfortunately it's not that simple if you take into account the Win '95
>toolbar.

You could also set the form's position property to poScreenCenter.

Rich

Other Threads