• 如何给CTreeCtrl 添加右键菜单


    首先定义右键消息函数:

        afx_msg  void  OnRBClick(NMHDR* pNMHDR, LRESULT* pResult);    

        然后在消息循环中定义消息对应关系:

        ON_NOTIFY(NM_RCLICK, ID_TREECTRL, OnRbClick)

        接着定义消息函数内容:

        void OnRBClick(NMHDR* pNMHDR, LRESULT* pResult)

        {

               CPoint point;

               GetCursorPos(&point);

               CPoint pointInTree = point;

               m_TreeCtrl.ScreenToClient(&pointInTree);

               HTREEITEM item;

               UINT flag = TVHT_ONITEM;

               item = m_TreeCtrl.HitTest(pointInTree, &flag);

               if(item != NULL)

               {

                      m_TreeCtrl.SelectItem(item);

                      CMenu menu;

                      menu.LoadMenu(IDR_MENU1);

                      menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | 

                                 TPM_RIGHTBUTTON, point.x, point.y, this, NULL);

               }

        }


  • 相关阅读:
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
    Live2D 看板娘
  • 原文地址:https://www.cnblogs.com/myitm/p/2091446.html
Copyright © 2020-2023  润新知