www.pudn.com > ShortCutEx.rar > DropTargetToolBar.cpp, change:2004-07-30,size:1436b
// DropTargetToolBar.cpp: implementation of the CDropTargetToolBar class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "DropTargetToolBar.h" #include "CSCToolBar.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CDropTargetToolBar::CDropTargetToolBar(HWND hWnd) :CDropTarget(hWnd) { m_pToolBar = NULL; } CDropTargetToolBar::~CDropTargetToolBar() { } bool CDropTargetToolBar::OnDrop(FORMATETC* pFmtEtc, STGMEDIUM& medium, DWORD *pdwEffect) { if(pFmtEtc->cfFormat == CF_HDROP && medium.tymed == TYMED_HGLOBAL) { HDROP hDrop = (HDROP)GlobalLock(medium.hGlobal); if(hDrop != NULL) { TCHAR szFileName[MAX_PATH]; UINT cFiles = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0); for(UINT i = 0; i < cFiles; ++i) { DragQueryFile(hDrop, i, szFileName, sizeof(szFileName)); if(DROPEFFECT_COPY & *pdwEffect) { //copy the file or dir m_pToolBar->AddFile(szFileName,TRUE); } else if(DROPEFFECT_MOVE & *pdwEffect) { //move the file or dir ::MessageBox(m_hTargetWnd, "Add the code to handle Move","Info", MB_OK); } } //DragFinish(hDrop); // base class calls ReleaseStgMedium } GlobalUnlock(medium.hGlobal); } return true; }