Buenos dias Foristas,
Quiero recorrer las opciones las opciones de un menu para averiguar que opcion se ejecuta cuando selecciono la opcion, este proceso los realizado mediante el siguiente proceso y obtengo la lista de todos opciones por menu, pero requiero obtener el nombre de la accion que ejecuto. Esto es para genertar un archivo con las opciones del menu. Adjunto el framento de codigo conque obtengo los items y descripciones . pero quiero obtener es el programa que ejecuto ejemplo quiero obtener el datos
TABLASGEN para identificar que programa ejecuta ya que nombre del objeto lo manejo como variable, gracias por su ayuda
Código:
object M_TABLASGEOGRAFICA: TMenuItem
Caption = 'Menu Tablas Datos Geograficos'
Hint = 'M_TABLASGEOGRAFICA--Menu Tablas Datos Geograficos'
object COUNTRY: TMenuItem
Caption = 'Mantenimiento Codigos de Paises'
Hint = 'PAISMST--Mantenimiento Codigos de Paises'
OnClick = TABLASGEN
end
Código:
procedure TFPGMMST.SpeedButtonActPgmMstClick(Sender: TObject);
var
i:integer;
Z:integer;
p:string;
D:string;
W_ACTION:STRING;
MENUITEM :TMenuItem;
MENUITEMP:TMenuItem;
NotifyEvent:TNotifyEvent;
mp:string;
begin
// TABLASGEN ;
// CONSULTASGEN ;
Z := fmenu.componentCount -1 ; // FMENU LA FORMA DONDE ESTAN LOS MENU
for i:= 0 to Z do begin
if fmenu.components[i] is TmenuItem then begin
mp:='';
MENUITEM:= fmenu.components[i] as TMenuItem ;
if MENUITEM.hasparent = true then Begin // NOMBRE DEL MENU DE LA OPCION
MP:= MENUITEM.parent.name;
end;
p:= fmenu.components[i].name;
D:= Trim(MENUITEM.Caption); // DESCRIPCION DE LA OPCION
NotifyEvent:= MENUITEM.OnClick ;
//IF NotifyEvent.
if (D <> '-') AND (D<>'') then begin
// CREAR OPCION DEL MENU EN ARCHIVO DE OPCIONES
if not pgmmst.findkey([p]) then begin
pgmmst.append;
pgmmst.FieldByName('ACTIVO').asString := 'A';
pgmmst.FieldByName('PGMCODE').asString := P;
PgmMst.FieldByName('NOMBRE').asString := D;
PgmMst.FieldByName('DPGMCODE').asString := D;
PgmMst.fieldbyname('MENUNAME').asstring := MP ;
PgmMst.FieldByName('PUBLICO').asString := 'N';
PgmMst.post;
PgmMst.ApplyUpdates(0);
end;
// ACTUALIZAR LA OPCION DEL MENU
if pgmmst.findkey([p]) then begin
if Trim(PgmMst.fieldbyname('MENUNAME').asstring) = '' then begin
PgmMst.Edit;
PgmMst.fieldbyname('MENUNAME').asstring := MP ;
PgmMst.post;
PgmMst.ApplyUpdates(0);
end;
end;
end;
end;
end;
end;