T_QRBand.Parent := tntini.ReadString('Parent', TempComponent.Name, ''); // 오류가 납니다. 제 생각에는 string을 wincontrol 로 바꿔 줘야 되는것 같은데 어떻게 하는지 모르겠습니다.
아래와 같이 저장을 하였는데 저장된 값을 불러 와서 어떻게 적용을 하여야 되는지.... 너무 많이 질문을 드리죠?
procedure TRPTEditF.dxButton3Click(Sender: TObject);
var
i : integer;
StreamF : TFileStream;
tntini : TIniFile;
T_QuickRep : TQuickRep;
begin
if TRPSave.Execute then
begin
StreamF := TFileStream.Create(TRPSave.FileName, fmOpenWrite or fmCreate);
tntini := TIniFile.Create(copy(TRPSave.FileName,1, length(TRPSave.FileName)-3)+'.IRP');
try
for i := RPTBlankF.ComponentCount-1 downto 0 do
begin
if RPTBlankF.Components[i] is TQuickRep then
begin
StreamF.WriteComponent(RPTBlankF.Components[i]);
end;
end;
for i := RPTBlankF.ComponentCount-1 downto 0 do
if RPTBlankF.Components[i] is TQRBand then
begin
StreamF.WriteComponent(RPTBlankF.Components[i]);
tntini.WriteString('Parent', RPTBlankF.Components[i].Name, TQRBand(RPTBlankF.Components[i].GetParentComponent).Name);
end;
for i := RPTBlankF.ComponentCount-1 downto 0 do
begin
if RPTBlankF.Components[i] is TQRLabel then begin
StreamF.WriteComponent(RPTBlankF.Components[i]);
tntini.WriteString('Parent', RPTBlankF.Components[i].Name, TQRBand(RPTBlankF.Components[i].GetParentComponent).Name);
end else if RPTBlankF.Components[i] is TQRDBText then begin
StreamF.WriteComponent(RPTBlankF.Components[i]);
tntini.WriteString('Parent', RPTBlankF.Components[i].Name, TQRBand(RPTBlankF.Components[i].GetParentComponent).Name);
end else if RPTBlankF.Components[i] is TQRMemo then begin
StreamF.WriteComponent(RPTBlankF.Components[i]);
tntini.WriteString('Parent', RPTBlankF.Components[i].Name, TQRBand(RPTBlankF.Components[i].GetParentComponent).Name);
end else if RPTBlankF.Components[i] is TQRShape then begin
StreamF.WriteComponent(RPTBlankF.Components[i]);
tntini.WriteString('Parent', RPTBlankF.Components[i].Name, TQRBand(RPTBlankF.Components[i].GetParentComponent).Name);
end else if RPTBlankF.Components[i] is TQRExpr then begin
StreamF.WriteComponent(RPTBlankF.Components[i]);
tntini.WriteString('Parent', RPTBlankF.Components[i].Name, TQRBand(RPTBlankF.Components[i].GetParentComponent).Name);
end else if RPTBlankF.Components[i] is TQRSubDetail then begin
StreamF.WriteComponent(RPTBlankF.Components[i]);
tntini.WriteString('Parent', RPTBlankF.Components[i].Name, TQRBand(RPTBlankF.Components[i].GetParentComponent).Name);
end else if RPTBlankF.Components[i] is TQRStringsBand then begin
StreamF.WriteComponent(RPTBlankF.Components[i]);
tntini.WriteString('Parent', RPTBlankF.Components[i].Name, TQRBand(RPTBlankF.Components[i].GetParentComponent).Name);
end else if RPTBlankF.Components[i] is TQRGroup then begin
StreamF.WriteComponent(RPTBlankF.Components[i]);
tntini.WriteString('Parent', RPTBlankF.Components[i].Name, TQRBand(RPTBlankF.Components[i].GetParentComponent).Name);
end else if RPTBlankF.Components[i] is TQRSysData then begin
StreamF.WriteComponent(RPTBlankF.Components[i]);
tntini.WriteString('Parent', RPTBlankF.Components[i].Name, TQRBand(RPTBlankF.Components[i].GetParentComponent).Name);
end else if RPTBlankF.Components[i] is TQRExprMemo then begin
StreamF.WriteComponent(RPTBlankF.Components[i]);
tntini.WriteString('Parent', RPTBlankF.Components[i].Name, TQRBand(RPTBlankF.Components[i].GetParentComponent).Name);
end else if RPTBlankF.Components[i] is TQRRichText then begin
StreamF.WriteComponent(RPTBlankF.Components[i]);
tntini.WriteString('Parent', RPTBlankF.Components[i].Name, TQRBand(RPTBlankF.Components[i].GetParentComponent).Name);
end else if RPTBlankF.Components[i] is TQRDBRichText then begin
StreamF.WriteComponent(RPTBlankF.Components[i]);
tntini.WriteString('Parent', RPTBlankF.Components[i].Name, TQRBand(RPTBlankF.Components[i].GetParentComponent).Name);
end else if RPTBlankF.Components[i] is TQRImage then begin
StreamF.WriteComponent(RPTBlankF.Components[i]);
tntini.WriteString('Parent', RPTBlankF.Components[i].Name, TQRBand(RPTBlankF.Components[i].GetParentComponent).Name);
end else if RPTBlankF.Components[i] is TQRDBImage then begin
StreamF.WriteComponent(RPTBlankF.Components[i]);
tntini.WriteString('Parent', RPTBlankF.Components[i].Name, TQRBand(RPTBlankF.Components[i].GetParentComponent).Name);
end;
end;
finally
tntini.Free;
StreamF.Free;
end;
end;
end;
var
i : integer;
StreamF : TFileStream;
T_Control : TControl;
TempComponent : TComponent;
Temp_Form : TForm;
tntini : TIniFile;
T_QuickRep : TQuickRep;
T_QRBand : TQRBand;
T_QRLabel : TQRLabel;
T_QRDBText : TQRDBText;
T_QRMemo : TQRMemo;
T_QRExpr : TQRExpr;
T_QRSysData : TQRSysData;
T_QRExprMemo : TQRExprMemo;
T_QRRichText : TQRRichText;
T_QRDBImage : TQRDBImage;
T_QRImage : TQRImage;
T_QRDBRichText : TQRDBRichText;
begin
if TRPOpen.Execute then
begin
Temp_Form := TForm.Create(Self);
StreamF := TFileStream.Create(TRPOpen.FileName, fmOpenRead);
tntini := TIniFile.Create(copy(TRPOpen.FileName,1, length(TRPSave.FileName)-3)+'.IRP');
try
while StreamF.Position < StreamF.Size do
begin
TempComponent := StreamF.ReadComponent(nil);
Temp_Form.InsertComponent(TempComponent);
if TempComponent is TQuickRep then
begin
T_QuickRep := TQuickRep(TempComponent);
T_QuickRep.Parent := Temp_Form;
// memo1.Lines.Add(T_QuickRep.Name);
end;
if TempComponent is TQRBand then
begin
T_QRBand := TQRBand(TempComponent);
// T_Control := TControl(Temp_Form.FindComponent(tntini.ReadString('Parent', TempComponent.Name, '')));
// T_QRBand.Parent := Temp_Form.FindComponent(tntini.ReadString('Parent', TempComponent.Name, nil));
T_QRBand.Parent := T_QuickRep;
end;
if TempComponent is TQRLabel then
begin
T_QRLabel := TQRLabel(TempComponent);
T_QRLabel.Parent := T_QRBand;
// T_QRLabel.Parent := TWinControl(Temp_Form.FindComponent(tntini.ReadString('Parent', TempComponent.Name, 'Temp_Form')));
// memo1.Lines.Add(T_QRLabel.Parent.Name+'ttttttttttt');
end;
if TempComponent is TQRDBText then
begin
T_QRDBText := TQRDBText(TempComponent);
T_QRDBText.Parent := TWinControl(Temp_Form.FindComponent(tntini.ReadString('Parent', TempComponent.Name, 'Temp_Form'))); <<= Paraent 값 부분이 문제가 있습니다.
memo1.Lines.Add(TempComponent.Name);
end;
end;
T_QuickRep.Enabled := true;
// T_QuickRep.preview;
Temp_Form.Show;
finally
StreamF.Free;
end;
end;
end;