Ir al contenido


Foto

[TRUCO DELPHI] Tu Propio inspector de Objectos.


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

#1 sir.dev.a.lot

sir.dev.a.lot

    Advanced Member

  • Miembros
  • PipPipPip
  • 545 mensajes
  • Location127.0.0.1

Escrito 26 agosto 2016 - 08:24

[TRUCO DELPHI] Tu Propio inspector de Objectos.

 

Debes de adicionar esta unidad


delphi
  1. uses TypInfo;

Ahora en este codigo, veras las propiedades del objeto que desees.


delphi
  1. procedure ObjectInspector(
  2. Obj : TObject;
  3. Items : TStrings );
  4. var
  5. n : integer;
  6. PropList : TPropList;
  7. begin
  8. n := 0;
  9. GetPropList(
  10. Obj.ClassInfo,
  11. tkProperties + [ tkMethod ],
  12. @PropList );
  13. while( (Nil <> PropList[ n ]) and
  14. (n < High(PropList)) ) do
  15. begin
  16. Items.Add(
  17. PropList[ n ].Name + ': ' +
  18. PropList[ n ].PropType^.Name );
  19. Inc( n );
  20. end;
  21. end;

Ejemplo de uso:


delphi
  1. ObjectInspector( ListBox1, ListBox1.Items );

Saludos!


  • 1




IP.Board spam blocked by CleanTalk.