VC视图中响应右键菜单

继续VC编程,这次所说的是关于在VC++中响应右键菜单,就是在点击右键的时候显示下拉菜单。下面给出实现过程,本来以为很复杂,其实只要响应一个函数即可。

在View中找到下面这个函数。加入所需代码,其中的ID***表示你的要加载的菜单。

void CtexADOView::OnContextMenu(CWnd*  pWnd , CPoint point)
{
	CMenu testMenu;
	testMenu.LoadMenuW(IDR_MENU_RBUT);
	testMenu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, point.x, point.y, this) ;
}

如果你有什么好的方法,欢迎指教,谢谢.

 标签: MFC, VC, 右键, 菜单, OnContextMenu

作者  :  sailor

仅仅看明白了还不够,能把别人给讲明白了才算及格。


  1. MurphyL
    1#
    MurphyL

    好吧~折腾代码的都是苦命的娃~~

    November 1st, 2011 at 11:00 pm 回复
      1. sailor
        sailor

        相当苦命啊!!!

        November 30th, 2011 at 02:48 pm 回复
  2. 我还是看不懂哇··

    November 1st, 2011 at 11:11 pm 回复
      1. sailor
        sailor

        术业有专攻[face:daxiao]

        November 30th, 2011 at 02:49 pm 回复
  3. 邓肯
    3#
    邓肯

    [face:daxiao]专业的代码 一阵眼花[face:han]

    November 3rd, 2011 at 12:07 am 回复
      1. sailor
        sailor

        嗯,我们这苦逼的专业啊

        November 30th, 2011 at 02:50 pm 回复
  4. 小嘉
    4#
    小嘉

    搞VC啦??

    November 4th, 2011 at 12:09 am 回复
      1. sailor
        sailor

        vc是本行~[face:han]

        November 30th, 2011 at 02:50 pm 回复
  5. 没学过表示 不懂[face:daku]

    November 4th, 2011 at 03:49 pm 回复
      1. sailor
        sailor

        术业有专攻~~

        November 30th, 2011 at 02:51 pm 回复
  6. 寒意
    6#
    寒意

    [face:daku][face:sad]

    November 4th, 2011 at 11:10 pm 回复
      1. sailor
        sailor

        怎么了这是?

        November 30th, 2011 at 02:51 pm 回复
  7. MurphyL
    7#
    MurphyL

    又睡了?~~~

    November 5th, 2011 at 08:49 pm 回复
      1. sailor
        sailor

        现在醒了!![face:daxiao][face:daxiao]

        November 30th, 2011 at 02:52 pm 回复
  8. 代码达人呀

    November 7th, 2011 at 11:32 am 回复
      1. sailor
        sailor

        非达人也,折腾而已

        November 30th, 2011 at 02:52 pm 回复
  9. win8迷
    9#
    win8迷

    [face:han]VC达人啊。。。

    November 8th, 2011 at 07:38 pm 回复
      1. sailor
        sailor

        嘿嘿,达人不敢说啊,不懂的太多

        November 30th, 2011 at 02:53 pm 回复
  10. su
    10#
    su

    又到这里了啊 呵呵

    November 9th, 2011 at 10:02 am 回复
      1. sailor
        sailor

        欢迎常来~~~~~

        November 30th, 2011 at 02:53 pm 回复
  11. 好可爱的小人啊 呵呵

    November 9th, 2011 at 10:02 am 回复
      1. sailor
        sailor

        嘿嘿,不过感觉他有点调皮啊

        November 30th, 2011 at 02:55 pm 回复
  12. 哇塞,,这主题好漂亮啊,怎么弄的啊

    November 9th, 2011 at 11:48 am 回复
      1. sailor
        sailor

        用的别人的~[face:daxiao]

        November 30th, 2011 at 02:55 pm 回复
  13. 工作室
    13#
    工作室

    学习笔记的习惯很好,我一直喜欢这么做,之后再遇到查阅很方便

    November 9th, 2011 at 03:11 pm 回复
      1. sailor
        sailor

        嗯,就是不想找的太烦

        November 30th, 2011 at 02:56 pm 回复
  14. 小嘉
    14#
    小嘉

    评论框太花了。[face:han]

    学好C++,以后好找工作!

    November 10th, 2011 at 04:12 pm 回复
      1. sailor
        sailor

        C++好找工作??[face:han][face:han][face:han]

        November 30th, 2011 at 02:56 pm 回复
          1. 不骗你

            November 30th, 2011 at 05:39 pm 回复
              1. sailor
                sailor

                工资高吗?

                December 2nd, 2011 at 12:54 pm 回复
                  1. 还可以。yunio网盘知道不?http://www.zaixianle.com/yunio.html
                    那公司也招。工资上万。

                    December 2nd, 2011 at 12:56 pm
                  2. sailor
                    sailor

                    你给的地址是404~

                    December 2nd, 2011 at 12:59 pm
                  3. 后面还差.html
                    不知道为什么,提交评论,自动没了。

                    December 2nd, 2011 at 01:01 pm
  15. 这种技术哥不懂啊!

    November 11th, 2011 at 09:03 am 回复
      1. sailor
        sailor

        术业有专攻而已~~

        November 30th, 2011 at 02:57 pm 回复
  16. IT路人
    16#
    IT路人

    我最近在学C#,累啊

    November 12th, 2011 at 07:24 pm 回复
      1. sailor
        sailor

        额,我至今没有学过C#,.net那一套不怎么了解

        November 30th, 2011 at 02:58 pm 回复
  17. netyang
    17#
    netyang

    越来越看不懂了!!![face:daku]

    November 13th, 2011 at 03:40 pm 回复
      1. sailor
        sailor

        术业有专攻而已啦

        November 30th, 2011 at 02:58 pm 回复
  18. 三人帮
    18#
    三人帮

    你消失很久了嘛

    November 15th, 2011 at 05:55 pm 回复
      1. sailor
        sailor

        嗯,真的很久了这次!太忙啊!

        November 30th, 2011 at 03:00 pm 回复
  19. 于泽鹏
    19#
    于泽鹏

    好久没来了![face:daxiao]

    November 16th, 2011 at 09:57 am 回复
      1. sailor
        sailor

        嗯,欢迎常来~嘿嘿

        November 30th, 2011 at 03:00 pm 回复


最新文章