关于SetMenuItemInfo

shadowstory80 2008-06-30 09:07:33
我用下面的方法设置“最近文件“重画,SetMenuItemInfo的返回值为1 但是“最近文件“没有重画,不知道到为什么?
请各位指教,谢谢!

void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
{
CMDIFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
if(bSysMenu) {
return;
}
int n = 0;
int nIndexMax = pPopupMenu-> GetMenuItemCount();
int nID = 0;
for(nIndex = 0;nIndex < nIndexMax;nIndex++) {
nID = pPopupMenu->GetMenuItemID(nIndex);
MENUITEMINFO MenuItemInfo;
//TCHAR szBuf[255];
//memset(szBuf,0,sizeof(szBuf));
memset(&MenuItemInfo,0,sizeof(MenuItemInfo));
MenuItemInfo.cbSize = sizeof (MENUITEMINFO);
MenuItemInfo.fMask = MIIM_DATA |MIIM_STATE | MIIM_ID;// ?个?型很??

if(nID >= 57616 && nID <= 57631 ) {
n = GetMenuItemInfo(pPopupMenu->m_hMenu ,nID,FALSE,&MenuItemInfo);
MenuItemInfo.fType |= MF_OWNERDRAW;
n = SetMenuItemInfo(pPopupMenu->m_hMenu ,nID,FALSE,&MenuItemInfo);
}
}
}
...全文
319 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
shen_wei 2011-12-10
  • 打赏
  • 举报
回复
Members to retrieve or set. It can be one or more of these values. Value Description 
MIIM_CHECKMARKS Retrieves or sets the hbmpChecked and hbmpUnchecked members.
MIIM_DATA Retrieves or sets the dwItemData member.
MIIM_ID Retrieves or sets the wID member.
MIIM_STATE Retrieves or sets the fState member.
MIIM_SUBMENU Retrieves or sets the hSubMenu member.
MIIM_TYPE Retrieves or sets the fType and dwTypeData members
牛 魔 王 2011-12-10
  • 打赏
  • 举报
回复
ls正解
willson93639450 2008-06-30
  • 打赏
  • 举报
回复
不好意思 主菜单第一个弹出菜单索引应该是0,不是1。上面搞错了
willson93639450 2008-06-30
  • 打赏
  • 举报
回复
CWnd::OnInitMenuPopup
afx_msg void OnInitMenuPopup( CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu );

Parameters

pPopupMenu

Specifies the menu object of the pop-up menu. May be temporary and should not be stored for later use.

nIndex

Specifies the index of the pop-up menu in the main menu.

bSysMenu

TRUE if the pop-up menu is the Control menu; otherwise FALSE.


1。还需要处理WM_MEASUREITEM WM_DRAWITEM消息

2。SetMenuItemInfo之前要设置MenuItemInfo.fMask |=MIIM_TYPE

3。另外:
你的nIndex用法不好
而且没必要整个主菜单所有弹出菜单都遍历一回,因为recent files 一般都放在 nIndex == 1的弹出菜单里面
scq2099yt 2008-06-30
  • 打赏
  • 举报
回复
up

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧