Put an object in the middle of the form - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Put an object in the middle of the form

porodoroporodoro Posts: 230Member
[b][red]This message was edited by porodoro at 2006-1-3 7:9:28[/red][/b][hr]
[b][red]This message was edited by porodoro at 2006-1-3 7:8:50[/red][/b][hr]
I've tryed this :

Panel1.top := (form1.Height - form1.height) + panel1.height div panel1.Height+form1.top;
panel1.left := (form1.width - form1.width) +form1.width div panel1.width ;


but it doesnt seem to work in all cases..




Comments

  • zibadianzibadian Posts: 6,349Member
    : [b][red]This message was edited by porodoro at 2006-1-3 7:9:28[/red][/b][hr]
    : [b][red]This message was edited by porodoro at 2006-1-3 7:8:50[/red][/b][hr]
    : I've tryed this :
    :
    : Panel1.top := (form1.Height - form1.height) + panel1.height div panel1.Height+form1.top;
    : panel1.left := (form1.width - form1.width) +form1.width div panel1.width ;
    :
    :
    : but it doesnt seem to work in all cases..
    :
    :
    :
    :
    :
    The formula for the middle is:
    [code]
    Panel1.Left := (Form1.ClientWidth div 2) - (Panel1.Width div 2);
    [/code]
    Your formula is this:
    [code]
    panel1.left := 0+form1.width div panel1.width;
    [/code]
    since Form1.Width - Form1.Width = 0 for every value in Width. Also the Top and Left of controls are relative to the top-left corner of the form.
  • porodoroporodoro Posts: 230Member
    Thanks ;).
    and thats for the top (Y):

    panel1.top:= (Form1.Clientheight div 2) - (Panel1.height div 2);
  • jobromediajobromedia Posts: 168Member
    : Thanks ;).
    : and thats for the top (Y):
    :
    : panel1.top:= (Form1.Clientheight div 2) - (Panel1.height div 2);
    :
    Hi, may I add a suggestion?

    JEDI JVCL has a form scale component that will automatically scale the form you have done, so the component will not only be placed in the middle, but also resized propotional to the form.
  • porodoroporodoro Posts: 230Member
    : : Thanks ;).
    : : and thats for the top (Y):
    : :
    : : panel1.top:= (Form1.Clientheight div 2) - (Panel1.height div 2);
    : :
    : Hi, may I add a suggestion?
    :
    : JEDI JVCL has a form scale component that will automatically scale the form you have done, so the component will not only be placed in the middle, but also resized propotional to the form.
    :
    i'll have it in mind.
Sign In or Register to comment.