Ejemplo n.º 1
0
void Explorerplusplus::OnApplicationToolbarRClick()
{
	MENUITEMINFO mii;

	TCHAR szTemp[64];
	LoadString(m_hLanguageModule,IDS_APPLICATIONBUTTON_NEW,
		szTemp,SIZEOF_ARRAY(szTemp));

	mii.cbSize		= sizeof(mii);
	mii.fMask		= MIIM_ID|MIIM_STRING;
	mii.dwTypeData	= szTemp;
	mii.wID			= IDM_APP_NEW;

	/* Add the item to the menu. */
	InsertMenuItem(m_hToolbarRightClickMenu,7,TRUE,&mii);

	/* Set it to be owner drawn. */
	SetMenuItemOwnerDrawn(m_hToolbarRightClickMenu,7);

	OnMainToolbarRClick();

	mii.cbSize	= sizeof(mii);
	mii.fMask	= MIIM_DATA;
	GetMenuItemInfo(m_hToolbarRightClickMenu,7,TRUE,&mii);

	/* Free the owner drawn data. */
	free((void *)mii.dwItemData);

	/* Now, remove the item from the menu. */
	DeleteMenu(m_hToolbarRightClickMenu,7,MF_BYPOSITION);
}
void CContainer::InsertBookmarksIntoMenuInternal(HMENU hMenu,
Bookmark_t *pBookmark,int iStartPos)
{
	MENUITEMINFO		mi;
	Bookmark_t			ChildBookmark;
	Bookmark_t			SiblingBookmark;
	CustomMenuInfo_t	*pcmi = NULL;
	HRESULT				hr;
	BOOL				res;

	/* pBookmark may be NULL when creating a menu
	for a folder on the bookmarks toolbar, when that
	folder has no children. */
	if(pBookmark == NULL)
	{
		mi.cbSize		= sizeof(mi);
		mi.fMask		= MIIM_STRING|MIIM_ID;
		mi.wID			= IDM_BOOKMARKS_BOOKMARKTHISTAB;
		mi.dwTypeData	= _T("Bookmark This Tab...");
		res = InsertMenuItem(hMenu,0,TRUE,&mi);

		SetMenuItemOwnerDrawn(hMenu,0);

		return;
	}

	if(pBookmark->Type == BOOKMARK_TYPE_BOOKMARK)
	{
		mi.cbSize		= sizeof(mi);
		mi.fMask		= MIIM_STRING|MIIM_ID;
		mi.wID			= g_iStartId++;
		mi.dwTypeData	= pBookmark->szItemName;
		res = InsertMenuItem(hMenu,iStartPos,TRUE,&mi);

		SetMenuItemOwnerDrawn(hMenu,iStartPos);

		mi.cbSize		= sizeof(mi);
		mi.fMask		= MIIM_DATA;
		res = GetMenuItemInfo(hMenu,iStartPos,TRUE,&mi);

		pcmi = (CustomMenuInfo_t *)mi.dwItemData;

		pcmi->dwItemData = (ULONG_PTR)pBookmark->pHandle;
	}
	else
	{
		HMENU hSubMenu;

		hSubMenu = CreateMenu();

		InsertMenu(hMenu,iStartPos,MF_BYPOSITION|MF_POPUP,1010,pBookmark->szItemName);

		mi.cbSize		= sizeof(mi);
		mi.fMask		= MIIM_SUBMENU;
		mi.hSubMenu		= hSubMenu;
		SetMenuItemInfo(hMenu,iStartPos,TRUE,&mi);
		SetMenuItemOwnerDrawn(hMenu,iStartPos);

		mi.cbSize		= sizeof(mi);
		mi.fMask		= MIIM_STRING|MIIM_ID;
		mi.wID			= IDM_BOOKMARKS_BOOKMARKTHISTAB;
		mi.dwTypeData	= _T("Bookmark This Tab...");
		res = InsertMenuItem(hSubMenu,0,TRUE,&mi);
		SetMenuItemOwnerDrawn(hSubMenu,0);

		hr = m_Bookmark.GetChild(pBookmark,&ChildBookmark);

		if(SUCCEEDED(hr))
		{
			/* Only insert a separator if this item actually
			has children. */
			mi.cbSize		= sizeof(mi);
			mi.fMask		= MIIM_FTYPE;
			mi.fType		= MFT_SEPARATOR;
			res = InsertMenuItem(hSubMenu,1,TRUE,&mi);
			SetMenuItemOwnerDrawn(hSubMenu,1);

			InsertBookmarksIntoMenuInternal(hSubMenu,&ChildBookmark,
				BOOKMARK_SUBMENU_POSITION_START);
		}
	}

	hr = m_Bookmark.GetNextBookmarkSibling(pBookmark,&SiblingBookmark);

	if(SUCCEEDED(hr))
	{
		InsertBookmarksIntoMenuInternal(hMenu,&SiblingBookmark,iStartPos + 1);
	}
}