Ejemplo n.º 1
0
DROPEFFECT FileScrapDropDlg::OnDragOver(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))
        {
            CPoint sDragPoint(aPoint);
            ClientToScreen(&sDragPoint);
            sMyDragImage->DragMove(sDragPoint);
        }
    }
    else
    {
        if (mDropTarget.isUseDropHelper() == XPR_TRUE)
        {
            CPoint sDragPoint(aPoint);
            mDropTarget.getDropHelper()->DragOver(&sDragPoint, sDropEffect);
        }
    }

    return sDropEffect;
}
Ejemplo n.º 2
0
	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 );
		}
	}
Ejemplo n.º 3
0
void CSpiroView::OnMouseMove(UINT nFlags, CPoint point) 
{
	if (m_bMovingPencil || m_pFigureDrag != NULL)  // the user is dragging the pencil location
	{
		CPoint ptWindow(point);
		ClientToScreen(&ptWindow);
		CRect	rectWindow;
		GetWindowRect(&rectWindow);
		ptWindow.Offset(-rectWindow.left, -rectWindow.top);

		CImageList* pImList = m_bMovingPencil? &GetApp()->m_imageList : m_pILDragFigure;

		ENSURE(pImList != NULL);
		if (m_bStartDrag)
		{
			ENSURE(m_pFigureDrag != NULL);
			m_bStartDrag = false;
			CSpiroRect rect;
			m_pFigureDrag->GetBoundingRect(&rect);
			rect.Scale(m_nZoomNumer, m_nZoomDenom);
			CDC* pDC = GetDC();
			ENSURE(pDC != NULL);
			OnPrepareDC(pDC);
			pDC->LPtoDP(&rect);
			ReleaseDC(pDC);
			rect.InflateRect(4, 4);
			InvalidateRect(&rect);
			pImList->DragLeave(this);
			UpdateWindow();
			pImList->DragEnter(this, ptWindow);
		}
		else
			pImList->DragMove(ptWindow);

		return;
	}

	CScrollView::OnMouseMove(nFlags, point);
}
Ejemplo n.º 4
0
DROPEFFECT BookmarkToolBar::OnDragOver(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))
        {
            CPoint sDragPoint(aPoint);
            ClientToScreen(&sDragPoint);
            sMyDragImage->DragMove(sDragPoint);
        }
    }
    else
    {
        if (mDropTarget.isUseDropHelper() == XPR_TRUE)
        {
            CPoint sDragPoint(aPoint);
            mDropTarget.getDropHelper()->DragOver(&sDragPoint, sDropEffect);
        }
    }

    CToolBarCtrl &sToolBarCtrl = GetToolBarCtrl();

    TBBUTTON sTbButton = {0};
    TBINSERTMARK sTbInsertMark = {0};
    xpr_sint_t sHitTest = GetToolBarCtrl().HitTest(&aPoint);
    xpr_sint_t sInsertHitTest = -1;
    if (sToolBarCtrl.InsertMarkHitTest(&aPoint, &sTbInsertMark) && sTbInsertMark.iButton >= 0)
        sInsertHitTest = sTbInsertMark.iButton;

    xpr_sint_t sBookmark, sInsert;
    if (XPR_TEST_BITS(aKeyState, MK_SHIFT) && XPR_TEST_BITS(aKeyState, MK_CONTROL))
    {
        sInsert = -1;
        sBookmark = -1;
    }
    else
    {
        if (sHitTest < 0 || sInsertHitTest >= 0)
        {
            if (sTbInsertMark.dwFlags == TBIMHT_AFTER)
            {
                sTbInsertMark.dwFlags = 0;
                sInsertHitTest++;
            }

            if (sHitTest == -1)
                sInsertHitTest = -1;

            sInsert = sInsertHitTest;
            sBookmark = -1;
        }
        else
        {
            sInsert = -1;
            sBookmark = sHitTest;
        }
    }

    BookmarkMgr &sBookmarkMgr = BookmarkMgr::instance();

    if (sBookmark >= sBookmarkMgr.getCount())
        sBookmark = -1;

    if (sBookmark != -1)
    {
        sDropEffect = DROPEFFECT_LINK;

        BookmarkItem *sBookmarkItem = sBookmarkMgr.getBookmark(sBookmark);
        if (sBookmarkItem != XPR_NULL)
        {
            xpr_bool_t sGetPidl = XPR_TRUE;
            LPITEMIDLIST sFullPidl = XPR_NULL;

            if (IsNetItem(sBookmarkItem->mPath.c_str()))
                sGetPidl = WnetMgr::instance().isConnectedServer(sBookmarkItem->mPath);

            if (sGetPidl == XPR_TRUE)
                sFullPidl = Path2Pidl(sBookmarkItem->mPath);

            if (sFullPidl != XPR_NULL && IsFileSystemFolder(sFullPidl))
            {
                sDropEffect = DROPEFFECT_MOVE;

                if (aKeyState & MK_ALT)          sDropEffect = DROPEFFECT_LINK;
                else if (aKeyState & MK_CONTROL) sDropEffect = DROPEFFECT_COPY;
                else if (aKeyState & MK_SHIFT)   sDropEffect = DROPEFFECT_MOVE;
                else
                {
                    switch (gOpt->mConfig.mDragDefaultFileOp)
                    {
                    case DRAG_FILE_OP_DEFAULT:  sDropEffect = DROPEFFECT_MOVE; break;
                    case DRAG_FILE_OP_COPY:     sDropEffect = DROPEFFECT_COPY; break;
                    case DRAG_FILE_OP_LINK:     sDropEffect = DROPEFFECT_LINK; break;
                    default:                    sDropEffect = DROPEFFECT_MOVE; break;
                    }
                }
            }
            else
            {
                HRESULT       sHResult;
                LPSHELLFOLDER sShellFolder = XPR_NULL;
                LPCITEMIDLIST sPidl        = XPR_NULL;

                fxfile::base::Pidl::getSimplePidl(sFullPidl, sShellFolder, sPidl);

                sHResult = E_FAIL;
                LPDROPTARGET sDropTarget = XPR_NULL;

                if (sShellFolder != XPR_NULL && sPidl != XPR_NULL)
                {
                    sHResult = sShellFolder->GetUIObjectOf(GetSafeHwnd(),
                        1,
                        (LPCITEMIDLIST *)&sPidl,
                        IID_IDropTarget,
                        XPR_NULL,
                        (LPVOID *)&sDropTarget);
                }

                xpr_bool_t sSucceeded = XPR_FALSE;

                if (SUCCEEDED(sHResult) && sDropTarget != XPR_NULL)
                {
                    POINTL sPointL = {0};
                    ClientToScreen(&aPoint);
                    sPointL.x = aPoint.x;
                    sPointL.y = aPoint.y;

                    DWORD sTempDropEffect = DROPEFFECT_MOVE | DROPEFFECT_COPY | DROPEFFECT_LINK;

                    sHResult = sDropTarget->DragEnter(aOleDataObject->m_lpDataObject, aKeyState, sPointL, &sTempDropEffect);
                    if (SUCCEEDED(sHResult))
                    {
                        sHResult = sDropTarget->DragOver(aKeyState, sPointL, &sTempDropEffect);
                        sSucceeded = SUCCEEDED(sHResult) && sTempDropEffect != 0;
                    }
                }

                COM_RELEASE(sDropTarget);
                COM_RELEASE(sShellFolder);

                if (sSucceeded == XPR_TRUE)
                    sDropEffect = DROPEFFECT_MOVE;
                else
                {
                    sBookmark = -1;
                    sDropEffect = DROPEFFECT_NONE;
                }
            }

            COM_FREE(sFullPidl);
        }
        else
        {
            sBookmark = -1;
            sDropEffect = DROPEFFECT_NONE;
        }
    }

    if (sBookmark == -1)
    {
        // Insert Bookmark
        if (mOldBookmark >= 0)
        {
            sToolBarCtrl.GetButton(mOldBookmark, &sTbButton);
            sToolBarCtrl.SetState(sTbButton.idCommand, TBSTATE_ENABLED);
        }

        if (mOldInsert != sInsert)
        {
            sTbInsertMark.iButton = sInsert;
            sToolBarCtrl.SetInsertMark(&sTbInsertMark);
        }

        sDropEffect = DROPEFFECT_LINK;
    }
    else
    {
        // Run Program or File Operation
        if (mOldInsert >= 0)
        {
            sTbInsertMark.iButton = -1;
            sToolBarCtrl.SetInsertMark(&sTbInsertMark);
        }

        if (mOldBookmark != sBookmark)
        {
            sToolBarCtrl.GetButton(mOldBookmark, &sTbButton);
            sToolBarCtrl.SetState(sTbButton.idCommand, TBSTATE_ENABLED);

            sToolBarCtrl.GetButton(sBookmark, &sTbButton);
            sToolBarCtrl.SetState(sTbButton.idCommand, TBSTATE_MARKED | TBSTATE_PRESSED | TBSTATE_ENABLED);
        }
    }

    mOldInsert = sInsert;
    mOldBookmark = sBookmark;

    if (XPR_IS_NOT_NULL(mObserver))
    {
        mObserver->onBookmarkToolBarStatus(*this, mOldBookmark, mOldInsert, sDropEffect);
    }

    return sDropEffect;
}