Ir al contenido


Foto

Convertir Texto a Forma con componentes

twritecomponent TextToForm FormToText

  • Por favor identifícate para responder
No hay respuestas en este tema

#1 makina

makina

    Member

  • Miembros
  • PipPip
  • 19 mensajes

Escrito 31 agosto 2017 - 03:54

Hola que tal.
tengo la necesidad de convertir en Run Time  el texto de la estructura de un  TForm con sus componentes visuales, no visuales y sus eventos a partir de texto como este

el cual es la estructura de un  TForm con un TEdit y un TTable


delphi
  1. object fforma: TForm
  2. Left = 1162
  3. Top = 216
  4. Caption = 'Hola'
  5. ClientHeight = 462
  6. ClientWidth = 484
  7. Color = clBtnFace
  8. Font.Charset = DEFAULT_CHARSET
  9. Font.Color = clWindowText
  10. Font.Height = -11
  11. Font.Name = 'Tahoma'
  12. Font.Style = []
  13. OldCreateOrder = False
  14. Position = poDesigned
  15. Visible = True
  16. PixelsPerInch = 96
  17. TextHeight = 13
  18. object editx: TEdit
  19. Left = 20
  20. Top = 50
  21. Width = 150
  22. Height = 21
  23. TabOrder = 0
  24. Text = 'editx'
  25. end
  26. object tabla: TTable
  27. end
  28. end

Este texto lo obtengo con esta función


delphi
  1. function ComponentToStringProc(sComponent: string): string;
  2. var
  3. BinStream:TMemoryStream;
  4. StrStream: TStringStream;
  5. s: string;
  6. sForm:TForm;
  7. begin
  8. sform:=Tform(FindComponent(sComponent));
  9. if sForm<> nil then
  10. begin
  11. BinStream := TMemoryStream.Create;
  12. try
  13. StrStream := TStringStream.Create(s);
  14. try
  15. BinStream.WriteComponent(sform);
  16. BinStream.Seek(0, soFromBeginning);
  17. ObjectBinaryToText(BinStream, StrStream);
  18. StrStream.Seek(0, soFromBeginning);
  19. Result:= StrStream.DataString;
  20. finally
  21. StrStream.Free;
  22. end;
  23. finally
  24. BinStream.Free
  25. end;
  26. end;

Tendrán alguna sugerencia de como lograr esto?

 

Muchas Gracias por anticipado. 

 

 

Saludos desde México

 

 

 

 

 

 

 


  • 0




IP.Board spam blocked by CleanTalk.