Ver Mensaje Individual
  #3  
Antiguo 29-11-2012
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Reputación: 21
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
Comandant,

Cita:
Empezado por Comandant
Como puedo obtener las propiedas de un objeto por ej. un panel en donde se despliege mi popmenu
Las propiedades de un objeto pueden ser obtenidas y modificadas en Runtime por medio de RTTI (Run-Time Type Information)

Revisa este código:
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, TypInfo, Grids;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Memo1: TMemo;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure ActiveControlChanged(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// Evento de Control del Focus sobre el Form1 por medio de la Matriz de Controles y RTTI
procedure TForm1.ActiveControlChanged(Sender: TObject);
var
   PropInfo: PPropInfo;
   i: Integer;
begin
   for i := 0 to ControlCount - 1 do
   begin
      if TWinControl(Controls[i]).Focused then
      begin
         PropInfo := GetPropInfo(Self.Controls[i].ClassInfo,'Color');
         if Assigned(PropInfo) then
            SetOrdProp(Controls[i], PropInfo, ord(clYellow));
      end
      else
      begin
         PropInfo := GetPropInfo(Self.Controls[i].ClassInfo,'Color');
         if Assigned(PropInfo) then
            SetOrdProp(Controls[i], PropInfo, ord(clWindow));
      end;
   end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
   // Activa el Evento de Control de Focus en el Form1
   Screen.OnActiveControlChange := ActiveControlChanged;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  // Desactiva el Evento de Control de Focus en el Form1
  Screen.OnActiveControlChange := nil;
end;

end.
El código anterior cambia en Runtime el color del componente activo que tenga definida la propiedad Color.

Revisa estos links:
Espero sea útil

Nelson.

Última edición por nlsgarcia fecha: 29-11-2012 a las 17:15:35.
Responder Con Cita