Hello
We need to read the Top & Left coordinates of a Window and for some reason we are not getting the
correct values.
Please see the code below.
**************************************************************
unit Utilities;
procedure TfrmUtilities.FormShow(Sender: TObject);
begin
Main.frmMain.LoadWindowSettings('UtilitiesWindow', Self);
ShowMessage('Utilities Top -> ' + IntToStr(frmUtilities.Top));
ShowMessage('Utilities Left -> ' + IntToStr(frmUtilities.Left));
end;**************************************************************
**************************************************************
unit Main;
procedure TfrmMain.LoadWindowSettings(myWindow: string; myForm: TForm);
var
myIniFile : TIniFile;
myIniFileName : string;
begin
myIniFileName := ExtractFilePath(Application.ExeName) +
ChangeFileExt(ExtractFileName(Application.ExeName), '.ini');
myIniFile := TIniFile.Create(myIniFileName);
try
myForm.Top := myIniFile.ReadInteger(myWindow,'Top',-1);
myForm.Left := myIniFile.ReadInteger(myWindow,'Left',-1);
myForm.Height := myIniFile.ReadInteger(myWindow,'Height',-1);
myForm.Width := myIniFile.ReadInteger(myWindow,'Width',-1);
finally
myIniFile.Free;
end;
end;
**************************************************************
**************************************************************
EDS.ini
[UtilitiesWindow]
Top=462
Left=894
Height=406
Width=401
**************************************************************
Procedure TfrmUtilities.FormShow is calling procedure LoadWindowSettings in unit Main. The
LoadWindowSettings is reading the EDS.ini file for the dimension and coordinates of the frmUtilities
Window. This works fine.
Right after the LoadWindowSettings is called, we read and display the cordinates of the frmUtilities
window. We assume that it should be equal to the values of Top and left cordinates that was read from
the EDS.ini file. However, it is completely different. When we run the ShowMessage commands we get:
Utilities Top -> 66
Utilities Left -> 66
Why is this so?
Regards,
Georges
We need to read the Top & Left coordinates of a Window and for some reason we are not getting the
correct values.
Please see the code below.
**************************************************************
unit Utilities;
procedure TfrmUtilities.FormShow(Sender: TObject);
begin
Main.frmMain.LoadWindowSettings('UtilitiesWindow', Self);
ShowMessage('Utilities Top -> ' + IntToStr(frmUtilities.Top));
ShowMessage('Utilities Left -> ' + IntToStr(frmUtilities.Left));
end;**************************************************************
**************************************************************
unit Main;
procedure TfrmMain.LoadWindowSettings(myWindow: string; myForm: TForm);
var
myIniFile : TIniFile;
myIniFileName : string;
begin
myIniFileName := ExtractFilePath(Application.ExeName) +
ChangeFileExt(ExtractFileName(Application.ExeName), '.ini');
myIniFile := TIniFile.Create(myIniFileName);
try
myForm.Top := myIniFile.ReadInteger(myWindow,'Top',-1);
myForm.Left := myIniFile.ReadInteger(myWindow,'Left',-1);
myForm.Height := myIniFile.ReadInteger(myWindow,'Height',-1);
myForm.Width := myIniFile.ReadInteger(myWindow,'Width',-1);
finally
myIniFile.Free;
end;
end;
**************************************************************
**************************************************************
EDS.ini
[UtilitiesWindow]
Top=462
Left=894
Height=406
Width=401
**************************************************************
Procedure TfrmUtilities.FormShow is calling procedure LoadWindowSettings in unit Main. The
LoadWindowSettings is reading the EDS.ini file for the dimension and coordinates of the frmUtilities
Window. This works fine.
Right after the LoadWindowSettings is called, we read and display the cordinates of the frmUtilities
window. We assume that it should be equal to the values of Top and left cordinates that was read from
the EDS.ini file. However, it is completely different. When we run the ShowMessage commands we get:
Utilities Top -> 66
Utilities Left -> 66
Why is this so?
Regards,
Georges