本文介绍了如何从CMFCPopupMenu获取选定的命令ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在从CMFCPopupMenu获取选定的命令ID时遇到麻烦.有一个成员函数:
CMFCToolBarMenuButton * GetSelItem(),该函数应该返回指向当前所选菜单命令的指针,但是,我总是从该函数获取NULL.以下是我使用的代码,请帮忙!

CMFCPopupMenu * pPopupMenu = new CMFCPopupMenu;
if(pPopupMenu-> Create(pWnd,point.x,point.y,hMenu)){
CMFCToolBarMenuButton * button = pPopupMenu-> GetSelItem();
....
}

hMenu是正确的菜单句柄,而pWnd是弹出菜单的父窗口.但是,无论用户选择菜单的哪个命令,按钮始终为NULL.

非常感谢!

Hi, I'm having trouble getting the selected command ID from CMFCPopupMenu. There is a member function:
CMFCToolBarMenuButton *GetSelItem(), which is supposed to return a pointer to the currently selected menu command, however, I always get NULL from this function.  Below is the code I use, Please help!

CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu;
if(pPopupMenu->Create(pWnd, point.x, point.y, hMenu)){
   CMFCToolBarMenuButton *button = pPopupMenu->GetSelItem();
   ....
}

hMenu is the proper menu handle and pWnd is the parent window of the popup menu. However button is always NULL, no matter which command of the menu is selected by user.

Thanks a lot!

推荐答案


这篇关于如何从CMFCPopupMenu获取选定的命令ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 14:13