Ver Mensaje Individual
  #4  
Antiguo 29-11-2012
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola Commandant.

El último componente asociado al TPopupMenu (que lo mostró), lo podes obtener de la propiedad PopupComponent.

Código Delphi [-]
...
implentation

uses TypInfo;

function GetPropertyValue(puMenu: TPopupMenu; PropName: string): Variant;
var
  PInfo: PPropInfo;
begin
  with puMenu do
  begin
    PInfo:= GetPropInfo(PopupComponent.ClassInfo, PropName);
    if Assigned(PInfo) then
      Result := GetPropValue(PopupComponent, PropName);
  end;
end;
...

 (*  Llamadas de ejemplo *)

// muestra propiedad Text del componente asociado
procedure TForm1.MenuItemGetCaptionClick(Sender: TObject);
var
  v: Variant;
begin
  v:= GetPropertyValue(PopupMenu1, 'Text');
  if not VarIsClear(v) then
    ShowMessage(v);
end;

// muestra propiedad Tag del componente asociado
procedure TForm1.MenuItemGetTagClick(Sender: TObject);
var
  v: Variant;
begin
  v:= GetPropertyValue(PopupMenu1, 'Tag');
  if not VarIsClear(v) then
    ShowMessage(v);
end;

Saludos.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita