如何使用TrackPopupMenu打开弹出菜单的子菜单 [英] how to open submenus of a popup menu using TrackPopupMenu

查看:510
本文介绍了如何使用TrackPopupMenu打开弹出菜单的子菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于具有如下所示子菜单的弹出菜单

For a popupmenu having submenu as shown below

MainMenuItem1
MainMenuItem2->
             SubMenu2a
             SubMenu2b
MainMenuItem3





主弹出菜单可以使用
$打开b $ b



the main popupmenu can be opened using

mainMenu.TrackPopupMenu(TPM_NONOTIFY|TPM_RETURNCMD...);





用户可以移动光标到MainMenuItem2弹出子菜单。



是否可以通过编程方式打开主菜单以及处于打开状态的子菜单?



这样做的原因是让用户可以选择单击右键单击子菜单/主菜单。



The user can move the cursor to "MainMenuItem2" to popup the submenu.

Is it possible to open up the mainmenu along with the submenu in opened state programmatically?

The reason for doing this is to have an option for the user to select the submenuitem/mainmenuitem in one single right click.

推荐答案

我不确定它是否可行,但这样做应该打开主菜单的第一个SubMenu:



I am not sure if it will work, but doing this should open the first SubMenu of the main menu:

CMenu* pPopup = mainmenu.GetSubMenu(0);
pPopup->TrackPopupMenu( TPM_LEFTALIGN, ptMousePos.x, ptMousePos.y, this );





显然,你必须指定SubMenu应该打开的坐标。



如果你能用最新的编译你的程序MFC(使用功能包)您可以切换到 CMFCPopupMenu [ ^ ]。它更好,有一个可选的动画,有更多的方法



Obviously, you would have to specify the coordinates where the SubMenu should open.

If you can compile your program with the latest MFC (with the feature pack) you could switch to CMFCPopupMenu[^]. It is much nicer, with an optional animation and has more methods


是的,我只能使用解决方案显示子菜单,但是,

对不起,我的问题是如何只需右键单击即可显示主要上下文菜单及其子菜单。



无论如何,我完全放弃了这个功能。
Yes I can show only the submenu using the solution but,
sorry, my question was how to show a main-context-menu along with its sub-menu in a single right-click.

Anyway, I abandoned this feature altogether.


这篇关于如何使用TrackPopupMenu打开弹出菜单的子菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆