I'm using the LoadComponentFromFile and SaveComponentToFile posted here: How to save and restore a form?
The routines are working fine. However, after saving and loading the form I can not change any of the form's component's values. For example, I have the following:
MainForm.LoadComponentFromFile(CustomPrintDialog, FileName+'CustomPrintDialog.txt');
NewFinalDepth := CurrentChild.GetMaxDepth;
CustomPrintDialog.ToEditBox.Value := round(NewFinalDepth);
The ToEditBox.Value is not changed by the line where it is assigned NewFinalDepth. Is there a setting somewhere in the LoadComponent that is preventing the updating of ToEditBox.Value?
ToEditBox.EditorEnabled and Enabled are both True.
This is the CustomPrintDialog OkButtonClick and ToEditBoxChange routines.
procedure TCustomPrintDialog.OKBtnClick(Sender: TObject);
var
Filename : string;
begin
Filename := MainForm.GetCurrentFileName;
FileName := Copy(Filename, 0, LastDelimiter('.',Filename) - 1);
FileName := FileName + 'CustomPrintDialog.txt';
MainForm.SaveComponentToFile(CustomPrintDialog, FileName);
end;
The SaveComponentToFile restores the original values to CustomPrintDialog. Why?
procedure TCustomPrintDialog.ToEditBoxChange(Sender: TObject);
var
Inches, Value : integer;
begin
if not(TryStrToInt(ToEditBox.Text, Value)) then
exit;
try
if FromEditBox.Value < ToEditBox.Value then
begin
if PrintCoverSheetCheckBox.Checked then
Inches := LONGHEADINGLENGTH
else if PrintheadingCheckBox.Checked then
Inches := MEDIUMHEADINGLENGTH
else
Inches := NOHEADINGLENGTH;
SetInchesRequired(Inches); // Inches is paper length required to print document
end;
except
on EConvertError do
begin
end;
end;
end;