int fsODMenu::InsertMenu(CMenu *pMenu, int iWhere, CMenu *pMenuWhere)
{
	BOOL bMenuBar = FALSE;
	if (pMenuWhere == NULL)
	{
		pMenuWhere = CMenu::FromHandle (m_hMenu);
		bMenuBar = TRUE;
	}

	for (UINT i = 0; i < (UINT)pMenu->GetMenuItemCount (); i++)
	{
		CString strText;

		pMenu->GetMenuString (i, strText, MF_BYPOSITION);

		HMENU hMenu = CopyMenu (pMenu->GetSubMenu (i)->m_hMenu);
		CMenu *menu = CMenu::FromHandle (hMenu);

		pMenuWhere->InsertMenu (iWhere, MF_BYPOSITION | MF_POPUP,  (UINT_PTR) menu->m_hMenu, strText);

		AttachMenu (menu);
		AttachMenuItem (pMenuWhere, iWhere++)->bMenuBar = bMenuBar;
	}

	
	return pMenu->GetMenuItemCount ();
}
void fsODMenu::AttachMenu(CMenu *pMenu, BOOL bMenuBar)
{
	for (UINT i = 0; i < (UINT)pMenu->GetMenuItemCount (); i++)
	{
		UINT uState = pMenu->GetMenuState (i, MF_BYPOSITION);

		fsODMenuItemData* pData = AttachMenuItem (pMenu, i);
		pData->bMenuBar = bMenuBar;
		pData->bBold = pMenu->GetDefaultItem (GMDI_USEDISABLED, TRUE) == i;

		
		if (uState & MF_POPUP)
		{
			CMenu *pSubMenu = pMenu->GetSubMenu (i);
			AttachMenu (pSubMenu);	
		}
	}
}
void fsODMenu::Attach(CMenu *pMenu, BOOL bMainMenu)
{
	Detach ();
	m_hMenu = pMenu->m_hMenu;
	AttachMenu (pMenu, bMainMenu);
}
Beispiel #4
0
func Activate(object caller)
{
	return AttachMenu(caller);
}