拦截消息
WM_MENUSELECT
 
哪我怎么知道是哪个菜单项发出的呢

解决方案 »

  1.   

    不知你想实现什么?说清楚点,拦截菜单的的click消息处理onClick就行了啊
      

  2.   

    LRESULT CALLBACK WindowProc(
      HWND hwnd,       // handle to window
      UINT uMsg,       // WM_MENUSELECT
      WPARAM wParam,   // menu item (UINT) and flags (UINT)
      LPARAM lParam    菜单巨变
    );
    MF_BITMAP Item displays a bitmap. 
    MF_CHECKED Item is checked. 
    MF_DISABLED Item is disabled. 
    MF_GRAYED Item is grayed. 
    MF_HILITE Item is highlighted. 
    MF_MOUSESELECT Item is selected with the mouse. 
    MF_OWNERDRAW Item is an owner-drawn item. 
    MF_POPUP Item opens a drop-down menu or submenu. 
    MF_SYSMENU Item is contained in the window menu. The lParam parameter contains a handle to the menu associated with the message. 
      

  3.   

    LPARAM lParam    菜单巨变这是菜单句柄吗?可是它的handle是HMENU类型的
      

  4.   

    参照VC的代码吧
    VC不是可以对菜单有个before click的消息吗?
      

  5.   

    对于菜单消息可以这样。
    定义:
    procedure WMCommand(var Msg: TWMCommand); message WM_COMMAND;
    实现:
    procedure TMForm.WMCommand(var Msg: TWMCommand);
    begin
      if (Msg.ItemID = yourmenuitem.command)  the
      //这里的yourmenuitem就时被click的菜单,Tmenuitem
      Inherited;
    end;
      

  6.   

    我觉的是不是可以不用消息,而是通过菜单项的tag属性来实现
      

  7.   

    在菜单项的 OnClick 事件中有 XXXClick(Sender: TObject),其实 Sender 就是指哪个菜单项,你要操作它就用 TMenuItem(Sender).XXX 就行了,不过在使用类型转换前请判断 (ClassName = 'TMenuItem')。