Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.70 KB | None | 0 0
  1.   function GetParentRoot(p: TControl): TControl;
  2.   begin
  3.     if twincontrol(p).ClassName = 'TForm' then
  4.     begin
  5.       result := p;
  6.     end else
  7.     begin
  8.       inc(roots);
  9.       rootstr := rootstr + '.' + twincontrol(p).Name;
  10.       showmessage(rootstr);
  11.       result := GetParentRoot(TWinControl(p).Parent);
  12.     end;
  13.   end;
  14.   function ReadObjects: String;
  15.   var
  16.     FileStream: TFileStream;
  17.     R: TMyReader;
  18.     s: String;
  19.     i,i2: Integer;
  20.   begin
  21.     result := '';
  22.     try
  23.       FileStream := TFileStream.Create('test.dta',fmOpenReadWrite);
  24.       try
  25.         R  := TMyReader.Create(FileStream, 1024);
  26.         s  := 'TForm';
  27.         tc := TComponentClass(FindClass(s)).Create(nil);
  28.  
  29.         FileStream.ReadComponent(tc);
  30.         FileStream.Position := 0;
  31.  
  32.         for i := 0 to twincontrol(tc).ComponentCount-1 do
  33.         begin
  34.           rootstr := rootstr + 'this.';
  35.           if tc.Components[i].ClassName = 'TPanel' then
  36.           begin
  37.             roots := 0;
  38.             GetParentRoot(twincontrol(tc.Components[i]));
  39.  
  40.             //showmessage(inttostr(roots));
  41.             //showmessage(TWinControl(tc.components[i]).parent.ClassName);
  42.             //showmessage(twincontrol(tc.components[i]).Name);
  43.  
  44.             //for i2 := 0 to
  45.             begin
  46. //              result := result + '.';
  47. //              result := result + twincontrol(tc.components[i]).Name;
  48.             end;
  49.           end;
  50.         end
  51.       finally
  52.         FileStream.Free;
  53.       end;
  54.     except
  55.       on E : Exception do
  56.       begin
  57.         ShowMessage('Exception class name = '+E.ClassName);
  58.         ShowMessage('Exception message = '+E.Message);
  59.       end;
  60.     end;
  61.  
  62.     result := rootstr;
  63.   end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement