Menus - fazer um hint ou saber quando foi selecionado

Top  Previous  Next

    type

       TForm1 = class(TForm)

       ...

       private

         procedure WMMenuSelect(var Msg: TWMMenuSelect) ; message WM_MENUSELECT;

       end

    ...

    implementation

    ...

    procedure TForm1.WMMenuSelect(var Msg: TWMMenuSelect) ;

    var

       menuItem : TMenuItem;

       hSubMenu : HMENU;

    begin

       inherited// from TCustomForm (so that Application.Hint is assigned)

 

       menuItem := nil;

       if (Msg.MenuFlag <> $FFFFor (Msg.IDItem <> 0then

       begin

         if Msg.MenuFlag and MF_POPUP = MF_POPUP then

         begin

           hSubMenu := GetSubMenu(Msg.Menu, Msg.IDItem) ;

           menuItem := Self.Menu.FindItem(hSubMenu, fkHandle) ;

         end

         else

         begin

           menuItem := Self.Menu.FindItem(Msg.IDItem, fkCommand) ;

         end;

       end;

 

       miHint.DoActivateHint(menuItem) ;

    end; (*WMMenuSelect*)