Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure TForm2.FormularNeu1Click(Sender: TObject);
- var
- FileStream: TFileStream;
- ss: ansistring;
- tc: TComponent;
- roots: integer;
- rootstr: String;
- function ComponentToString(Component: TComponent): string;
- var
- BinStream:TMemoryStream;
- StrStream: TStringStream;
- s: string;
- begin
- BinStream := TMemoryStream.Create;
- try
- StrStream := TStringStream.Create(s);
- try
- BinStream.WriteComponent(Component);
- BinStream.Seek(0, soFromBeginning);
- ObjectBinaryToText(BinStream, StrStream);
- StrStream.Seek(0, soFromBeginning);
- Result := StrStream.DataString;
- finally
- StrStream.Free;
- end;
- finally
- BinStream.Free
- end;
- end;
- function GetParentRoot(p: TControl): TControl;
- begin
- if twincontrol(p).ClassName = 'TForm' then
- begin
- result := p;
- end else
- begin
- inc(roots);
- rootstr := rootstr + '.' + twincontrol(p).Name;
- result := GetParentRoot(TWinControl(p).Parent);
- end;
- end;
- function ReadObjects: String;
- var
- FileStream: TFileStream;
- R: TMyReader;
- s: String;
- i,i2: Integer;
- begin
- result := '';
- try
- FileStream := TFileStream.Create('test.dta',fmOpenReadWrite);
- try
- R := TMyReader.Create(FileStream, 1024);
- s := 'TForm';
- tc := TComponentClass(FindClass(s)).Create(nil);
- FileStream.ReadComponent(tc);
- FileStream.Position := 0;
- for i := 0 to twincontrol(tc).ComponentCount-1 do
- begin
- rootstr := rootstr + 'this.';
- if tc.Components[i].ClassName = 'TPanel' then
- begin
- roots := 0;
- GetParentRoot(twincontrol(tc.Components[i]));
- rootstr := rootstr + #10;
- //showmessage(inttostr(roots));
- //showmessage(TWinControl(tc.components[i]).parent.ClassName);
- //showmessage(twincontrol(tc.components[i]).Name);
- //for i2 := 0 to
- begin
- // result := result + '.';
- // result := result + twincontrol(tc.components[i]).Name;
- end;
- end;
- end
- finally
- FileStream.Free;
- end;
- except
- on E : Exception do
- begin
- ShowMessage('Exception class name = '+E.ClassName);
- ShowMessage('Exception message = '+E.Message);
- end;
- end;
- result := rootstr;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement