parent의 핸들값은 그때 그때 달라지기 때문에.... 저장한다고 해서 별 의미가 없을 것 같구여...
parent의 이름을 저장하면 될 것 같네요....
parent가 TPanel이고, 자신이 SSS라면...
TPanel(SSS.Parent).name 하면 parent의 이름을 가져올 수 있습니다...
에....주재환님의 글을 보고 조금 응용??? 해봅니다.
꼭 panel 이 아닐때.. Form이나 GroupBox 이런애들이 있을때 같이 쓰시면 되겠네욤.
if SSS.parent.ClassType = TPanel then Showmessage( TPanel(sss.Parent).name );
if SSS.parent.ClassType = TForm then Showmessage( TForm(sss.Parent).name );
if SSS.parent.ClassType = TGroupBox then Showmessage( TGroupbox(sss.Parent).name );
쩝..쓰고나서도 별 영양가가 없네요 ㅠㅠ
ini 파일 컨트롤은 머 아실테니.... 에혀..속쓰려..괜히 밥먹었넹.
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;
도움 주셔서 정말 감사 합니다. 그런데 아직도 한참 남았네요. 모르는게 너무 많아서 아직 많이 물어 볼게 많네요.
앞으로도 잘 부탁 드려요. 지금 만들고 잇는거는 폼 디자이너(quick report 전용)
procedure TRPTEditF.dxButton3Click(Sender: TObject); // 저장 부분입니다. (Quick Report 저장)
var
i, j : 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 := 0 to RPTBlankF.ComponentCount-1 do
begin
if RPTBlankF.Components[i] is TQRBand then
begin
StreamF.WriteComponent(RPTBlankF.Components[i]);
for j := 0 to TQRBand(RPTBlankF.Components[i]).ControlCount-1 do
begin
tntini.WriteString('Band', TQRBand(RPTBlankF.Components[i]).Controls[j].Name, RPTBlankF.Components[i].Name);
StreamF.WriteComponent(TQRBand(RPTBlankF.Components[i]).Controls[j]);
end;
end;
end;
finally
tntini.Free;
StreamF.Free;
end;
end;
end;
procedure TRPTEditF.dxButton5Click(Sender: TObject); // 로드 부분 입니다.(Quick Report 로드)
var
i, j : integer;
ComponentS : String;
Old_Position : int64;
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(TRPOpen.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;
end;
if TempComponent is TQRBand then
begin
T_QRBand := TQRBand(TempComponent);
T_QRBand.Parent := T_QuickRep;
end;
end;
StreamF.Position := 0;
while StreamF.Position < StreamF.Size do
begin
TempComponent := StreamF.ReadComponent(nil);
if TempComponent is TQRLabel then begin
ComponentS := tntini.ReadString('Band', TempComponent.Name, ComponentS);
Temp_Form.InsertComponent(TempComponent);
TQRLabel(TempComponent).Parent := TWinControl(Temp_Form.FindComponent(ComponentS));
end;
if TempComponent is TQRDBText then begin
ComponentS := tntini.ReadString('Band', TempComponent.Name, ComponentS);
Temp_Form.InsertComponent(TempComponent);
TQRDBText(TempComponent).Parent := TWinControl(Temp_Form.FindComponent(ComponentS));
end;
if TempComponent is TQRMemo then begin
ComponentS := tntini.ReadString('Band', TempComponent.Name, ComponentS);
Temp_Form.InsertComponent(TempComponent);
TQRMemo(TempComponent).Parent := TWinControl(Temp_Form.FindComponent(ComponentS));
end;
if TempComponent is TQRExpr then begin
ComponentS := tntini.ReadString('Band', TempComponent.Name, ComponentS);
Temp_Form.InsertComponent(TempComponent);
TQRExpr(TempComponent).Parent := TWinControl(Temp_Form.FindComponent(ComponentS));
end;
if TempComponent is TQRSysData then begin
ComponentS := tntini.ReadString('Band', TempComponent.Name, ComponentS);
Temp_Form.InsertComponent(TempComponent);
TQRSysData(TempComponent).Parent := TWinControl(Temp_Form.FindComponent(ComponentS));
end;
if TempComponent is TQRExprMemo then begin
ComponentS := tntini.ReadString('Band', TempComponent.Name, ComponentS);
Temp_Form.InsertComponent(TempComponent);
TQRExprMemo(TempComponent).Parent := TWinControl(Temp_Form.FindComponent(ComponentS));
end;
if TempComponent is TQRSysData then begin
ComponentS := tntini.ReadString('Band', TempComponent.Name, ComponentS);
Temp_Form.InsertComponent(TempComponent);
TQRSysData(TempComponent).Parent := TWinControl(Temp_Form.FindComponent(ComponentS));
end;
if TempComponent is TQRRichText then begin
ComponentS := tntini.ReadString('Band', TempComponent.Name, ComponentS);
Temp_Form.InsertComponent(TempComponent);
TQRRichText(TempComponent).Parent := TWinControl(Temp_Form.FindComponent(ComponentS));
end;
if TempComponent is TQRDBImage then begin
ComponentS := tntini.ReadString('Band', TempComponent.Name, ComponentS);
Temp_Form.InsertComponent(TempComponent);
TQRDBImage(TempComponent).Parent := TWinControl(Temp_Form.FindComponent(ComponentS));
end;
if TempComponent is TQRImage then begin
ComponentS := tntini.ReadString('Band', TempComponent.Name, ComponentS);
Temp_Form.InsertComponent(TempComponent);
TQRImage(TempComponent).Parent := TWinControl(Temp_Form.FindComponent(ComponentS));
end;
if TempComponent is TQRDBRichText then begin
ComponentS := tntini.ReadString('Band', TempComponent.Name, ComponentS);
Temp_Form.InsertComponent(TempComponent);
TQRDBRichText(TempComponent).Parent := TWinControl(Temp_Form.FindComponent(ComponentS));
end;
parent의 이름을 저장하면 될 것 같네요....
parent가 TPanel이고, 자신이 SSS라면...
TPanel(SSS.Parent).name 하면 parent의 이름을 가져올 수 있습니다...