本文介绍了为什么CMFCPopupMenu避免submeu的状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//Visual Studio 2008 sp 1

当我使用GetContextMenuManager()-> ShowPopupMenu()时,它避免了子菜单的状态.

//ShowPopupMenu(HMENU hmenuPopup,int x,int y,CWnd * pWndOwner,BOOL bOwnMessage = FALSE,BOOL bAutoDestroy = TRUE,BOOL bRightAlign = FALSE);

示例源代码

CMenu menu1,menu2;
menu.CreatePopupMenu();

menu1.AppendMenu(MF_STRING | MF_CHECKED ,WM_USER + 1,_T("A"));
menu2.AppendMenu(MF_STRING | MF_CHECKED ,WM_USER + 2,_T("SubMenu A"));

menu1.AppendMenu(MF_BYCOMMAND | MF_STRING | MF_POPUP,reinterpret_cast< uint_ptr>(menu2.Detach()),_T("Submenu"));

theApp.GetContextMenuManager()-> ShowPopupMenu(menu1.Detach(),x,y,this,TRUE,TRUE);


出现时,选中菜单"A",但没有选中子菜单A.

没有人知道为什么吗?

//Visual Studio 2008 sp 1

when I use GetContextMenuManager()->ShowPopupMenu(), it avoid submenu''s uistate.

//ShowPopupMenu(HMENU hmenuPopup, int x, int y, CWnd* pWndOwner, BOOL bOwnMessage = FALSE, BOOL bAutoDestroy = TRUE, BOOL bRightAlign = FALSE);

Example source code

CMenu menu1, menu2;
menu.CreatePopupMenu();

menu1.AppendMenu( MF_STRING | MF_CHECKED, WM_USER+1, _T("A") );
menu2.AppendMenu( MF_STRING | MF_CHECKED, WM_USER+2, _T("SubMenu A") );

menu1.AppendMenu( MF_BYCOMMAND | MF_STRING | MF_POPUP, reinterpret_cast<uint_ptr>(menu2.Detach()), _T("Submenu") );

theApp.GetContextMenuManager()->ShowPopupMenu(menu1.Detach(), x, y, this, TRUE, TRUE);


when it appeared, the menu "A" is checked, but SubMenu A wasn''t.

isn''t there anyone know why?

推荐答案

void CMFCToolBarMenuButton::CreateFromMenu(HMENU hMenu)


确实会产生子选单,但无法控制内部的检查状态...

您可以直接插入按钮(很简单),
或在创建呈现的种类后重新访问某些按钮:)


does produce a submenu, but does not control the checked state inside...

You could insert your buttons directly (it''s easy),
or reaccess some buttons after the creating of presented kind :)



这篇关于为什么CMFCPopupMenu避免submeu的状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 20:25