Recent

Author Topic: Left property fails while the form isn't showing  (Read 5466 times)

Zombat

  • New member
  • *
  • Posts: 7
Left property fails while the form isn't showing
« on: October 22, 2006, 11:51:44 pm »
When I try to set .Left when the form isn't showing, the position isn't set when I then call FormName.ShowModal;

I tested my code to see if it was due to my own stuff, but it seems that it will only allow me to change .Left when the form is showing... It may be the TLabel's autosize function that isn't working right before the form is shown, but that I'm not sure about....

Code: [Select]
procedure TfrmDirectDL.ResizeAll;
var
  I: integer;
begin
  I := lblLink.Left + lblLink.Width;
  if (lblSave.Left + lblSave.Width > I) then
    I := lblSave.Left + lblSave.Width;
  if (lblUser.Left + lblUser.Width > I) then
    I := lblUser.Left + lblUser.Width;
  if (lblPass.Left + lblPass.Width > I) then
    I := lblPass.Left + lblPass.Width;
  txtLink.Left := I + 8;
  while (txtLink.Left + txtLink.Width > Self.ClientWidth - 8) do
    txtLink.Width := txtLink.Width - 1;
  while (txtLink.Left + txtLink.Width < Self.ClientWidth - 8) do
    txtLink.Width := txtLink.Width + 1;
  txtSave.Left := txtLink.Left;
  txtSave.Width := txtLink.Width - cmdSave.Width - 4;
  cbAuth.Left := txtLink.Left;
  txtUser.Left := txtLink.Left;
  txtUser.Width := txtLink.Width;
  txtPass.Left := txtLink.Left;
  txtPass.Width := txtLink.Width;
  cbStart.Left := txtLink.Left;
end;


If I call the above function from a button's OnClick event, it works fine but when I call it from either FormCreate or FormShow, it doesn't work. Any help is appreciated.

 

TinyPortal © 2005-2018