mdi,sdi中如何隐藏菜单条? 但仍能响应菜单消息?
mdi,sdi中如何隐藏菜单条? 但仍能响应菜单消息? 问题点数:0、回复次数:3Top
1 楼ljzcom()回复于 2003-11-04 08:27:11 得分 0
friendly up upTop
2 楼databasesql(程序人生)回复于 2003-11-04 09:03:29 得分 0
void CMainFrame::OnButtonShowmenu()
{
// TODO: Add your command handler code here
m_bShow = !m_bShow;
CMenu* pMenu = GetMenu();
if( !m_bShow ) // 隐藏菜单
{
ASSERT(m_hMenu == NULL);
CMenu *tempMenu;
m_nMenuCount = pMenu->GetMenuItemCount();
m_hMenu = new HMENU[m_nMenuCount];
m_strMenu = new CString[m_nMenuCount];
HMENU *temphMenu = m_hMenu;;
CString *tempstrMenu = m_strMenu;
while(pMenu != NULL && pMenu->GetMenuItemCount() > 0)
{
tempMenu = pMenu->GetSubMenu(0);
*temphMenu = tempMenu->m_hMenu;
pMenu->GetMenuString(0,*tempstrMenu,MF_BYPOSITION);
temphMenu++;
tempstrMenu++;
pMenu->RemoveMenu(0, MF_BYPOSITION);
// force a redraw of the menu bar
DrawMenuBar();
}
}
else // 显示菜单
{
HMENU *temphMenu = m_hMenu;
CString *tempstrMenu = m_strMenu;
for(int i = 0; i < m_nMenuCount/*sizeof(m_hMenu)/sizeof(HMENU *)*/; i++)
{
pMenu->AppendMenu(MF_POPUP,(UINT) *temphMenu++,*tempstrMenu++);
DrawMenuBar();
}
delete [] m_hMenu;
delete [] m_strMenu;
m_hMenu = NULL;
m_strMenu = NULL;
}
}
Top
3 楼databasesql(程序人生)回复于 2003-11-04 09:04:48 得分 0
上面的代码是在SDI中隐藏,在MDI中我没试过,应该是一样的。Top




