petershaw9
asked on
.ini file
In my application, there are two report forms. when closing each report form, the report form write the left, top, height, width into .Ini file, so next time the report will show on position as that on last time.
When I click a button and produce a report A and close it, then click another button to generate another report B, and close it, thare are no problem.
When I produce report A and than report B, then close A( or B), it is still fine, but when I then close B(or A), I got the TExternalException message.
I find when write the form.left into the .ini file, the error message occurs.
The following is the procedure that write the .ini file
procedure WriteIni(formname : TForm);
var status : integer;
Ininame: string;
begin
Status := 1;
if not assigned(SptIni) then
begin
Ininame := ExtractFilePath(ParamStr(0 )) + 'fSptIni.ini';
SptIni := TIniFile.Create(Ininame);
end;
with SptIni do begin
case formname.WindowState of
wsNormal: begin
WriteInteger('Support', 'Left', formname.Left);
WriteInteger('Support', 'Top', formname.Top);
WriteInteger('Support', 'Width', formname.Width);
WriteInteger('Support', 'Height', formname.Height);
end;
wsMiniMized:
Status := 2;
wsMaximized:
Status := 3;
end;//case
if not formname.Active then
Status := 2;
{write status information}
SptIni.WriteInteger ('Support', 'Status', Status);
{destroy the IniFile object}
SptIni.Destroy;
end;
end;
Best regards
PeterShaw
When I click a button and produce a report A and close it, then click another button to generate another report B, and close it, thare are no problem.
When I produce report A and than report B, then close A( or B), it is still fine, but when I then close B(or A), I got the TExternalException message.
I find when write the form.left into the .ini file, the error message occurs.
The following is the procedure that write the .ini file
procedure WriteIni(formname : TForm);
var status : integer;
Ininame: string;
begin
Status := 1;
if not assigned(SptIni) then
begin
Ininame := ExtractFilePath(ParamStr(0
SptIni := TIniFile.Create(Ininame);
end;
with SptIni do begin
case formname.WindowState of
wsNormal: begin
WriteInteger('Support', 'Left', formname.Left);
WriteInteger('Support', 'Top', formname.Top);
WriteInteger('Support', 'Width', formname.Width);
WriteInteger('Support', 'Height', formname.Height);
end;
wsMiniMized:
Status := 2;
wsMaximized:
Status := 3;
end;//case
if not formname.Active then
Status := 2;
{write status information}
SptIni.WriteInteger ('Support', 'Status', Status);
{destroy the IniFile object}
SptIni.Destroy;
end;
end;
Best regards
PeterShaw
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.