コード例 #1
0
HRESULT __stdcall CBookmarksToolbarDropHandler::DragOver(DWORD grfKeyState,
	POINTL pt,DWORD *pdwEffect)
{
	UNREFERENCED_PARAMETER(grfKeyState);

	if(m_bAcceptData)
	{
		*pdwEffect = DROPEFFECT_COPY;
	}
	else
	{
		*pdwEffect = DROPEFFECT_NONE;
	}

	bool bAfter;
	int iButton = GetToolbarPositionIndex(pt,bAfter);

	if(iButton < 0)
	{
		int nButtons = static_cast<int>(SendMessage(m_hToolbar,TB_BUTTONCOUNT,0,0));

		TBINSERTMARK tbim;
		tbim.iButton = nButtons - 1;
		tbim.dwFlags = TBIMHT_AFTER;
		SendMessage(m_hToolbar,TB_SETINSERTMARK,0,reinterpret_cast<LPARAM>(&tbim));
	}
	else
	{
		TBINSERTMARK tbim;

		if(bAfter)
		{
			tbim.dwFlags = TBIMHT_AFTER;
		}
		else
		{
			tbim.dwFlags = 0;
		}

		tbim.iButton = iButton;
		SendMessage(m_hToolbar,TB_SETINSERTMARK,0,reinterpret_cast<LPARAM>(&tbim));
	}

	m_pDropTargetHelper->DragOver(reinterpret_cast<POINT *>(&pt),*pdwEffect);

	return S_OK;
}
コード例 #2
0
HRESULT __stdcall CBookmarksToolbarDropHandler::Drop(IDataObject *pDataObject,
	DWORD grfKeyState,POINTL pt,DWORD *pdwEffect)
{
	FORMATETC ftc = {CF_HDROP,0,DVASPECT_CONTENT,-1,TYMED_HGLOBAL};
	STGMEDIUM stg;

	HRESULT hr = pDataObject->GetData(&ftc,&stg);

	if(hr == S_OK)
	{
		DROPFILES *pdf = reinterpret_cast<DROPFILES *>(GlobalLock(stg.hGlobal));

		if(pdf != NULL)
		{
			bool bAfter;
			int iPosition = GetToolbarPositionIndex(pt,bAfter);

			if(iPosition < 0)
			{
				iPosition = static_cast<int>(SendMessage(m_hToolbar,TB_BUTTONCOUNT,0,0));
			}
			else
			{
				if(bAfter)
				{
					iPosition++;
				}
			}

			UINT nDroppedFiles = DragQueryFile(reinterpret_cast<HDROP>(pdf),0xFFFFFFFF,NULL,NULL);

			for(UINT i = 0;i < nDroppedFiles;i++)
			{
				TCHAR szFullFileName[MAX_PATH];
				DragQueryFile(reinterpret_cast<HDROP>(pdf),i,szFullFileName,
					SIZEOF_ARRAY(szFullFileName));

				if(PathIsDirectory(szFullFileName))
				{
					TCHAR szDisplayName[MAX_PATH];
					GetDisplayName(szFullFileName,szDisplayName,SHGDN_INFOLDER);

					CBookmark Bookmark(szDisplayName,szFullFileName,EMPTY_STRING);

					auto variantBookmarksToolbar = NBookmarkHelper::GetBookmarkItem(m_AllBookmarks,m_guidBookmarksToolbar);
					assert(variantBookmarksToolbar.type() == typeid(CBookmarkFolder));
					CBookmarkFolder &BookmarksToolbarFolder = boost::get<CBookmarkFolder>(variantBookmarksToolbar);

					BookmarksToolbarFolder.InsertBookmark(Bookmark,iPosition + i);
				}
			}

			GlobalUnlock(stg.hGlobal);
		}

		ReleaseStgMedium(&stg);
	}

	RemoveInsertionMark();
	m_pDropTargetHelper->Drop(pDataObject,reinterpret_cast<POINT *>(&pt),*pdwEffect);

	return S_OK;
}