Ejemplo n.º 1
0
void CSearchDialog::AddMenuEntries(LPITEMIDLIST pidlParent,
	const std::list<LPITEMIDLIST> &pidlItemList,DWORD_PTR dwData,HMENU hMenu)
{
	LPITEMIDLIST pidlComplete = ILCombine(pidlParent,pidlItemList.front());
	SFGAOF ItemAttributes = SFGAO_FOLDER;
	GetItemAttributes(pidlComplete,&ItemAttributes);
	CoTaskMemFree(pidlComplete);

	TCHAR szTemp[64];

	if((ItemAttributes & SFGAO_FOLDER) == SFGAO_FOLDER)
	{
		LoadString(GetInstance(),IDS_SEARCH_OPEN_FOLDER_LOCATION,
			szTemp,SIZEOF_ARRAY(szTemp));
	}
	else
	{
		LoadString(GetInstance(),IDS_SEARCH_OPEN_FILE_LOCATION,
			szTemp,SIZEOF_ARRAY(szTemp));
	}

	MENUITEMINFO mii;
	mii.cbSize		= sizeof(MENUITEMINFO);
	mii.fMask		= MIIM_STRING|MIIM_ID;
	mii.wID			= MENU_ID_OPEN_FILE_LOCATION;
	mii.dwTypeData	= szTemp;
	InsertMenuItem(hMenu,1,TRUE,&mii);
}
Ejemplo n.º 2
0
BOOL IsIdlDirectory(LPCITEMIDLIST pidl)
{
	SFGAOF Attributes;

	Attributes = SFGAO_FOLDER;

	GetItemAttributes(pidl,&Attributes);

	if(Attributes & SFGAO_FOLDER)
		return TRUE;

	return FALSE;
}
void Explorerplusplus::AddMenuEntries(LPITEMIDLIST pidlParent,
	const std::list<LPITEMIDLIST> &pidlItemList,DWORD_PTR dwData,HMENU hMenu)
{
	assert(dwData != NULL);

	FileContextMenuInfo_t *pfcmi = reinterpret_cast<FileContextMenuInfo_t *>(dwData);

	bool AddNewTabMenuItem = false;

	if(pfcmi->uFrom == FROM_LISTVIEW)
	{
		if(pidlItemList.size() == 1)
		{
			SFGAOF FileAttributes = SFGAO_FOLDER;

			LPITEMIDLIST pidlComplete = ILCombine(pidlParent,pidlItemList.front());
			GetItemAttributes(pidlComplete,&FileAttributes);
			CoTaskMemFree(pidlComplete);

			if(FileAttributes & SFGAO_FOLDER)
			{
				AddNewTabMenuItem = true;
			}
		}
	}
	else if(pfcmi->uFrom == FROM_TREEVIEW)
	{
		/* The treeview only contains folders,
		so the new tab menu item will always
		be shown. */
		AddNewTabMenuItem = true;
	}

	if(AddNewTabMenuItem)
	{
		MENUITEMINFO mii;
		TCHAR szTemp[64];

		LoadString(m_hLanguageModule,IDS_GENERAL_OPEN_IN_NEW_TAB,szTemp,SIZEOF_ARRAY(szTemp));
		mii.cbSize		= sizeof(mii);
		mii.fMask		= MIIM_STRING|MIIM_ID;
		mii.wID			= MENU_OPEN_IN_NEW_TAB;
		mii.dwTypeData	= szTemp;
		InsertMenuItem(hMenu,1,TRUE,&mii);
	}
}
Ejemplo n.º 4
0
TEST(GetItemAttributes, Simple)
{
	TCHAR szFullFileName[MAX_PATH];
	GetTestResourceFilePath(L"Metadata.jpg", szFullFileName, SIZEOF_ARRAY(szFullFileName));

	SFGAOF attributes;
	HRESULT hr = GetItemAttributes(szFullFileName, &attributes);
	ASSERT_TRUE(SUCCEEDED(hr));

	/* Since the exact list of
	attributes can vary by operating
	system version (i.e. newer
	versions of Windows can return
	newer properties), simply check
	that a few sample properties
	are present. */
	EXPECT_TRUE((attributes & SFGAO_CANCOPY) != 0);
	EXPECT_TRUE((attributes & SFGAO_FILESYSTEM) != 0);
	EXPECT_FALSE((attributes & SFGAO_FOLDER) != 0);
	EXPECT_FALSE((attributes & SFGAO_LINK) != 0);
}
Ejemplo n.º 5
0
HRESULT GetItemAttributes(const TCHAR *szItemParsingPath,SFGAOF *pItemAttributes)
{
	if(szItemParsingPath == NULL ||
		pItemAttributes == NULL)
	{
		return E_FAIL;
	}

	LPITEMIDLIST pidl = NULL;
	HRESULT hr;

	hr = GetIdlFromParsingName(szItemParsingPath,&pidl);

	if(SUCCEEDED(hr))
	{
		hr = GetItemAttributes(pidl,pItemAttributes);

		CoTaskMemFree(pidl);
	}

	return hr;
}
void CMyTreeView::UpdateParent(HTREEITEM hParent)
{
	if(hParent != NULL)
	{
		TVITEM tvItem;
		SFGAOF Attributes = SFGAO_HASSUBFOLDER;
		BOOL bRes;
		HRESULT hr;

		tvItem.mask		= TVIF_PARAM|TVIF_HANDLE;
		tvItem.hItem	= hParent;
		bRes = TreeView_GetItem(m_hTreeView,&tvItem);

		if(bRes)
		{
			hr = GetItemAttributes(m_pItemInfo[static_cast<int>(tvItem.lParam)].pidl,
				&Attributes);

			if(SUCCEEDED(hr))
			{
				/* If the parent folder no longer has any sub-folders,
				set its number of children to 0. */
				if((Attributes & SFGAO_HASSUBFOLDER) != SFGAO_HASSUBFOLDER)
				{
					tvItem.cChildren = 0;
					TreeView_Expand(m_hTreeView,hParent,TVE_COLLAPSE);
				}
				else
				{
					tvItem.cChildren = 1;
				}

				tvItem.mask		= TVIF_CHILDREN;
				tvItem.hItem	= hParent;
				TreeView_SetItem(m_hTreeView,&tvItem);
			}
		}
	}
}