//.h BOOL m_bAccept;//关联变量 CMenu *menuMain, *menuPopUp;//2个菜单 LPPOINT m_lpoint;//弹出坐标 afx_msg void OnMenuRecv();//映射 //.cpp //构造函数中初始化 menuMain = new CMenu; m_lpoint = new tagPOINT; VERIFY(menuMain->LoadMenu(IDR_MENU_POPUP)); menuPopUp = menuMain->GetSubMenu(0); //弹出菜单 ::GetCursorPos(m_lpoint); // 得到鼠标位置 menuPopUp->TrackPopupMenu(TPM_LEFTALIGN, m_lpoint->x, m_lpoint->y, this); //弹出 //点击check菜单 m_bAccept = !m_bAccept; menuPopUp->CheckMenuItem(ID_Menu_RECV, m_bAccept? MF_CHECKED: MF_UNCHECKED); menuPopUp->TrackPopupMenu(TPM_LEFTALIGN, m_lpoint->x, m_lpoint->y, this); //析构或者DestroyWindow进行释放 HMENU hmenu = menuMain->Detach(); menuMain->DestroyMenu(); menuPopUp = NULL; delete menuMain; menuMain = NULL; delete m_lpoint;
Check菜单
最新推荐文章于 2021-04-14 12:39:45 发布