Пример #1
0
ShellContext::ShellContext(BOOL *r, const _ITEMIDLIST * pidl)
{
	bool ext_verb;
	hMenu   = NULL;
	refc    = 0;
	*r      = FALSE;
	if (sh_get_uiobject(pidl, &pidlFull, &pidlItem, &psfFolder, IID_IContextMenu, (void**)&pContextMenu))
	{
		if((GetAsyncKeyState(VK_SHIFT) & 0x8000) == 0x8000)
			ext_verb = true;
		else
			ext_verb = false;

		hMenu = CreatePopupMenu();
		HRESULT hr = pContextMenu->QueryContextMenu(
			hMenu, 0, MIN_SHELL_ID, MAX_SHELL_ID,
			CMF_EXPLORE |CMF_CANRENAME | (ext_verb ? CMF_EXTENDEDVERBS : 0)
			);

		if (SUCCEEDED(hr))
		{
			*r=TRUE;
		}
	}
}
Пример #2
0
// first called when the mouse enters our target window space
STDMETHODIMP CDropTarget::DragEnter(LPDATAOBJECT pDataObject, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect)
{
	// don't set "*pdwEffect = DROPEFFECT_NONE"; that would adversely affect the drop target
	BOOL ok = FALSE;
	AddRef();
	if (m_pidl)
	{
		LPSHELLFOLDER psfFolder;
		LPITEMIDLIST pidlItem;
		LPITEMIDLIST pidlFull;
		if (sh_get_uiobject(m_pidl, &pidlFull, &pidlItem, &psfFolder, IID_IDropTarget, (void**)&m_pDropTarget))
		{
			HRESULT hr = m_pDropTarget->DragEnter(pDataObject, grfKeyState, pt, pdwEffect);
			if(SUCCEEDED(hr)) ok = TRUE;
		}
		if (psfFolder)      psfFolder   ->Release();
		if (pidlItem)       m_free(pidlItem);
		if (pidlFull)       m_free(pidlFull);
	}
	if(FALSE == ok) *pdwEffect = DROPEFFECT_NONE; // we can't understand this thing
	m_pDataObject = pDataObject;
	return S_OK;
}