各位大侠,请问在vc中怎样动态添加二级菜单(100分)

  • 主题发起人 主题发起人 guothreelove200
  • 开始时间 开始时间
G

guothreelove200

Unregistered / Unconfirmed
GUEST, unregistred user!
首先,要用createmenu生成一个空菜单,不能用loadmenu,然后用appendmenu添加菜单项,然后怎样才能为所添加的菜单项添加二级菜单?
 
代码:
void CPrdTreeView::OnRButtonDown(UINT nFlags, CPoint point) 
{
	CTreeView::OnRButtonDown(nFlags, point);
	
    CMenu PopupMenu;
	CMenu SubMenu;
	SubMenu.CreateMenu();
    SubMenu.AppendMenu(MF_STRING,1,"&new");
    SubMenu.AppendMenu(MF_STRING,2,"&open");
	
	PopupMenu.CreatePopupMenu();	
	PopupMenu.AppendMenu(MF_POPUP,(UINT)SubMenu.m_hMenu,"&file");
	PopupMenu.AppendMenu(MF_STRING,3,"&view");
	GetCursorPos(&point);
	CPoint PointInTree = point;
	ScreenToClient( &PointInTree);
	HTREEITEM hCurItem = GetTreeCtrl().HitTest(PointInTree,&nFlags);
	
	PopupMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,
		this);		
}
 
后退
顶部