void OnDragging( CPoint& point ){ if( m_bDragging ) { CPoint pt(point); ClientToScreen( &pt ); m_pDragImage->DragMove( pt ); m_pDragImage->DragShowNolock( FALSE ); CWnd* pDropWnd = CWnd::WindowFromPoint( pt ); ASSERT(pDropWnd); if( pDropWnd != m_pDropWnd ) { if( m_hDropItem ) { ((CTreeCtrl*)m_pDropWnd)->SelectDropTarget( NULL ); m_hDropItem = NULL; } if( m_nDropIndex != -1 ) { CListCtrl* pList = (CListCtrl*)m_pDropWnd; pList->SetItemState( m_nDropIndex, 0, LVIS_DROPHILITED ); pList->RedrawItems( m_nDropIndex, m_nDropIndex ); pList->UpdateWindow(); m_nDropIndex = -1; } } m_pDropWnd = pDropWnd; pDropWnd->ScreenToClient( &pt ); if( pDropWnd->IsKindOf(RUNTIME_CLASS(CTreeCtrl)) ) { UINT uFlags; m_hDropItem = ((CTreeCtrl*)pDropWnd)->HitTest( pt, &uFlags ); ((CTreeCtrl*)pDropWnd)->SelectDropTarget( m_hDropItem ); } else if( pDropWnd->IsKindOf(RUNTIME_CLASS(CListCtrl)) ) { UINT uFlags; CListCtrl* pList = (CListCtrl*)pDropWnd; pList->SetItemState( m_nDropIndex, 0, LVIS_DROPHILITED ); pList->RedrawItems( m_nDropIndex, m_nDropIndex ); m_nDropIndex = ((CListCtrl*)pDropWnd)->HitTest( pt, &uFlags ); pList->SetItemState( m_nDropIndex, LVIS_DROPHILITED, LVIS_DROPHILITED ); pList->RedrawItems( m_nDropIndex, m_nDropIndex ); pList->UpdateWindow(); } m_pDragImage->DragShowNolock( TRUE ); } }
DROPEFFECT BookmarkToolBar::OnDragEnter(COleDataObject *aOleDataObject, DWORD aKeyState, CPoint aPoint) { DROPEFFECT sDropEffect = DROPEFFECT_LINK; DragImage &sDragImage = DragImage::instance(); if (sDragImage.isMyDragging() == XPR_TRUE) { CImageList *sMyDragImage = sDragImage.getMyDragImage(); if (XPR_IS_NOT_NULL(sMyDragImage)) { sMyDragImage->DragEnter(GetDesktopWindow(), aPoint); sMyDragImage->DragShowNolock(XPR_TRUE); } } else { if (mDropTarget.isUseDropHelper() == XPR_TRUE) { CPoint sDragPoint(aPoint); IDataObject *sDataObject = aOleDataObject->GetIDataObject(XPR_FALSE); mDropTarget.getDropHelper()->DragEnter(GetSafeHwnd(), sDataObject, &sDragPoint, sDropEffect); } } mOldInsert = -1; mOldBookmark = -1; return sDropEffect; }
void BookmarkToolBar::OnDrop(COleDataObject *aOleDataObject, DROPEFFECT aDropEffect, CPoint aPoint) { CToolBarCtrl &sToolBarCtrl = GetToolBarCtrl(); DragImage &sDragImage = DragImage::instance(); if (sDragImage.isMyDragging() == XPR_TRUE) { CImageList *sMyDragImage = sDragImage.getMyDragImage(); if (XPR_IS_NOT_NULL(sMyDragImage)) { sMyDragImage->EndDrag(); sMyDragImage->DragShowNolock(XPR_FALSE); } } else { if (mDropTarget.isUseDropHelper() == XPR_TRUE) mDropTarget.getDropHelper()->DragLeave(); } if (mOldInsert >= 0) { TBINSERTMARK sTbInsertMark = {0}; sTbInsertMark.iButton = -1; sToolBarCtrl.SetInsertMark(&sTbInsertMark); } if (mOldBookmark >= 0) { TBBUTTON sTbButton = {0}; sToolBarCtrl.GetButton(mOldBookmark, &sTbButton); sToolBarCtrl.SetState(sTbButton.idCommand, TBSTATE_ENABLED); } if (XPR_IS_NOT_NULL(mObserver)) { mObserver->onBookmarkToolBarStatus(*this, -1, -1, DROPEFFECT_NONE); } COleDataObject *sOleDataObject = aOleDataObject; if (sOleDataObject->IsDataAvailable(mShellIDListClipFormat) == XPR_FALSE) return; // 3 Operation //-------------------------------------------------- // 1. Insert Bookmark Item // 2. Run Program & Bookmark File // 3. File Operation STGMEDIUM sStgMedium = {0}; FORMATETC sFormatEtc = {(CLIPFORMAT)mShellIDListClipFormat, XPR_NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; if (sOleDataObject->GetData(mShellIDListClipFormat, &sStgMedium, &sFormatEtc) == XPR_FALSE) return; if (mOldBookmark < 0) { OnDropInsertBookmark(&sStgMedium, mOldInsert); } else { xpr_bool_t sFileOperation = XPR_FALSE; BookmarkItem *sBookmarkItem = BookmarkMgr::instance().getBookmark(mOldBookmark); if (mOldBookmark >= 0 && sBookmarkItem != XPR_NULL) { LPITEMIDLIST sFullPidl = Path2Pidl(sBookmarkItem->mPath); sFileOperation = (sFullPidl != XPR_NULL && IsFileSystemFolder(sFullPidl)); COM_FREE(sFullPidl); } if (sFileOperation == XPR_TRUE) { if (aDropEffect == DROPEFFECT_LINK) OnDropShortcut(&sStgMedium, mOldBookmark); else OnDropFileOperation(&sStgMedium, aDropEffect, mOldBookmark); } else { OnDropTarget(sOleDataObject, aDropEffect, aPoint, mOldBookmark); } } if (XPR_IS_NOT_NULL(sStgMedium.pUnkForRelease)) { ::ReleaseStgMedium(&sStgMedium); } }
void FileScrapDropDlg::OnDrop(COleDataObject *aOleDataObject, DROPEFFECT aDropEffect, CPoint aPoint) { DragImage &sDragImage = DragImage::instance(); if (sDragImage.isMyDragging() == XPR_TRUE) { CImageList *sMyDragImage = sDragImage.getMyDragImage(); if (XPR_IS_NOT_NULL(sMyDragImage)) { sMyDragImage->EndDrag(); sMyDragImage->DragShowNolock(XPR_FALSE); } } else { if (mDropTarget.isUseDropHelper() == XPR_TRUE) { mDropTarget.getDropHelper()->DragLeave(); } } COleDataObject *sOleDataObject = aOleDataObject; if (sOleDataObject->IsDataAvailable(mShellIDListClipFormat) == XPR_FALSE) return; xpr_uint_t sGroupId = FileScrap::instance().getCurGroupId(); if (mDropTarget.isRightDrag() == XPR_TRUE) { cmd::FileScrapGroupDlg sDlg; if (sDlg.DoModal() != IDOK) return; xpr_uint_t sSelGroupId = sDlg.getSelGroupId(); if (sSelGroupId != FileScrap::InvalidGroupId) sGroupId = sSelGroupId; } STGMEDIUM sStgMedium = {0}; FORMATETC sFormatEtc = {mShellIDListClipFormat, XPR_NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; if (sOleDataObject->GetData(mShellIDListClipFormat, &sStgMedium, &sFormatEtc) == XPR_FALSE) return; LPIDA sIda = (LPIDA)::GlobalLock(sStgMedium.hGlobal); if (XPR_IS_NOT_NULL(sIda)) { xpr_sint_t sCount = sIda->cidl; LPCITEMIDLIST sPidl1 = XPR_NULL; // folder PIDL LPCITEMIDLIST sPidl2 = XPR_NULL; // item PIDL // get folder PIDL sPidl1 = (LPITEMIDLIST)(((xpr_byte_t *)sIda)+(sIda)->aoffset[0]); LPSHELLFOLDER sShellFolder = XPR_NULL, sShellFolderDesktop = XPR_NULL; ::SHGetDesktopFolder(&sShellFolderDesktop); HRESULT sHResult = sShellFolderDesktop->BindToObject(sPidl1, XPR_NULL, IID_IShellFolder, (LPVOID *)&sShellFolder); if (FAILED(sHResult) || XPR_IS_NULL(sShellFolder)) { sShellFolder = sShellFolderDesktop; sShellFolderDesktop = XPR_NULL; } LPCITEMIDLIST *sPidls = new LPCITEMIDLIST[sCount]; xpr_sint_t i; xpr_sint_t sCount2 = 0; for (i = 0; i < sCount; ++i) { // get item PIDL and get full-qualified PIDL sPidl2 = (LPCITEMIDLIST)(((xpr_byte_t *)sIda)+(sIda)->aoffset[i+1]); if (IsFileSystem(sShellFolder, sPidl2)) { sPidls[sCount2] = sPidl2; sCount2++; } } FileScrap &sFileScrap = FileScrap::instance(); sFileScrap.addItem(sGroupId, sShellFolder, sPidls, sCount2); XPR_SAFE_DELETE_ARRAY(sPidls); COM_RELEASE(sShellFolder); COM_RELEASE(sShellFolderDesktop); ::GlobalUnlock(sStgMedium.hGlobal); } if (XPR_IS_NOT_NULL(sStgMedium.pUnkForRelease)) { ::ReleaseStgMedium(&sStgMedium); } }