我想实现如下功能:
1.当鼠标移动到菜单栏某项时,弹出对应的一个Dialog
2.当鼠标移出菜单栏该项且移出弹出的Dialog时,关闭Dialog。
问题:怎么判断鼠标在菜单栏哪一项?
请问下应当怎么实现呢?

解决方案 »

  1.   

    1、afx_msg   void   OnNcMouseMove(   UINT   nHitTest,   CPoint   point   ); 2、添加函数定义,实现你的功能 3、ON_WM_NCMOUSEMOVE()附:(下面的UINT值表示你的鼠标移到了非客户区的什么地方) HTBORDER       In   the   border   of   a   window   that   does   not   have   a   sizing   border. 
    HTBOTTOM       In   the   lower   horizontal   border   of   the   window. 
    HTBOTTOMLEFT       In   the   lower-left   corner   of   the   window   border. 
    HTBOTTOMRIGHT       In   the   lower-right   corner   of   the   window   border. 
    HTCAPTION       In   a   title-bar   area. 
    HTCLIENT       In   a   client   area. 
    HTERROR       On   the   screen   background   or   on   a   dividing   line   between   windows   (same   as   HTNOWHERE   except   that   the   DefWndProc   Windows   function   produces   a   system   beep   to   indicate   an   error). 
    HTGROWBOX       In   a   size   box. 
    HTHSCROLL       In   the   horizontal   scroll   bar. 
    HTLEFT       In   the   left   border   of   the   window. 
    HTMAXBUTTON       In   a   Maximize   button. 
    HTMENU       In   a   menu   area. 
    HTMINBUTTON       In   a   Minimize   button. 
    HTNOWHERE       On   the   screen   background   or   on   a   dividing   line   between   windows. 
    HTREDUCE       In   a   Minimize   button. 
    HTRIGHT       In   the   right   border   of   the   window. 
    HTSIZE       In   a   size   box   (same   as   HTGROWBOX). 
    HTSYSMENU       In   a   Control   menu   or   in   a   Close   button   in   a   child   window. 
    HTTOP       In   the   upper   horizontal   border   of   the   window. 
    HTTOPLEFT       In   the   upper-left   corner   of   the   window   border. 
    HTTOPRIGHT       In   the   upper-right   corner   of   the   window   border. 
    HTTRANSPARENT       In   a   window   currently   covered   by   another   window. 
    HTVSCROLL       In   the   vertical   scroll   bar. 
    HTZOOM       In   a   Maximize   button. 或者你可以这样: 
    BOOL   CMydilog::PreTranslateMessage(MSG*   pMsg)   

            if   (pMsg-> message   ==WM_NCMOUSEMOVE)//截取消息 
    if(pMsg-> wParam==HTCAPTION)//当鼠标在标题栏时响应,其它的用上面的几个UNIT 
          MessageBox( "Ok "); 
              return   CDialog::PreTranslateMessage(pMsg); 
    }
      

  2.   

    http://www.vckbase.com/document/viewdoc/?id=1240
      

  3.   

    假如菜单栏的每项高度是H那么鼠标点所在的项是item=point.y/H