Пример #1
0
inline HRESULT __stdcall ISimpleDropTarget::DragLeave(void)
{
	if (m_pdth) {              
		m_pdth->DragLeave();
	}
	m_DataObject = NULL; 
	dragInAction = false;
	OnDragLeave();
	PrevFancyRenderer = FancyRender;
	return S_OK;
}
Пример #2
0
HRESULT DropTarget::DragLeave() {
	// Tell the helper that we moved out of it so it can update the drag image.
	IDropTargetHelper* drop_helper = DropHelper();
	if (drop_helper)
		drop_helper->DragLeave();

	if (suspended_)
		return S_OK;

	OnDragLeave(current_data_object_);

	current_data_object_ = NULL;
	return S_OK;
}
Пример #3
0
LRESULT C_Edit::OnDrop(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	try {

		IDataObject* pdto = *reinterpret_cast<IDataObject**>(lParam);

		if (pdto) {

			HRESULT hres = E_FAIL;
			FORMATETC fmte = {CF_HDROP, NULL, DVASPECT_CONTENT, -1,	TYMED_HGLOBAL};
			STGMEDIUM medium;
			int files = 0;

			if (pdto && SUCCEEDED (pdto->GetData(&fmte, &medium))) {

				//char szFileDropped [MAX_PATH];

				files = DragQueryFile((HDROP)medium.hGlobal, 0xFFFFFFFF, NULL, 0);
			}

			OleSetClipboard(pdto);
			OleFlushClipboard();

			C_ClipboardPtr clipboard;

			clipboard.Create();
			
			if (clipboard) {

				if (0 == files) {

					clipboard->Load(CF_TEXT);

					short s = -1;
					clipboard->get_Type(&s);

					switch (s) {
					case CF_OEMTEXT:
					case CF_TEXT:

						BSTR bs = NULL;
						clipboard->get_Text(&bs);
						
						String s(bs);
						
						String::FreeBSTR(&bs);

						int len = s.GetLength();

						SetFocus();

						TCHAR t[1024];
						SendMessage(WM_GETTEXT, 1023, reinterpret_cast<LPARAM>(t));
						String old(t);

						POINT p = { 
							reinterpret_cast<POINT*>(wParam)->x, 
							reinterpret_cast<POINT*>(wParam)->y 
						};
						ScreenToClient(&p);

						int selpos = LOWORD(SendMessage(EM_CHARFROMPOS, 0, MAKELPARAM(p.x, p.y)));

						if (selpos >= 0 && selpos < old.GetLength()) {
							s = old.Left(selpos) + s + old.Right(old.GetLength() - selpos);
						}

						if (selpos < m_dwSelEnd) {

							m_dwSelStart += len;
							m_dwSelEnd += len;
						}

						SendMessage(WM_SETTEXT, 0, reinterpret_cast<LPARAM>(s.toLPCTSTR()));
						SendMessage(EM_SETSEL, selpos, selpos + len);
					}
				}
			}
		}

		OnDragLeave(uMsg, wParam, lParam, bHandled);
	}
	catch (C_STLNonStackException const &exception) {
		exception.Log(_T("Exception in C_Edit::OnCanDrop"));
	}

	return S_OK;
}
Пример #4
0
LRESULT C_Edit::OnCanDrop(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	try {//TODO: dropped text on toolbar must be streamed to tool tip

		*(BOOL*)wParam = TRUE;

		if (lParam) {

			POINT p = { 
				reinterpret_cast<POINT*>(lParam)->x, 
				reinterpret_cast<POINT*>(lParam)->y 
			};
			ScreenToClient(&p);

			int selpos = LOWORD(SendMessage(EM_CHARFROMPOS, 0, MAKELPARAM(p.x, p.y)));

			TCHAR t[1024];
			SendMessage(WM_GETTEXT, 1023, reinterpret_cast<LPARAM>(t));
			String old(t);

			if (selpos >= 0 && selpos < old.GetLength()) {
				
				DWORD dw = SendMessage(EM_POSFROMCHAR, selpos, 0);

				POINT dragpoint = {
					LOWORD(dw),
					HIWORD(dw)
				};

				if (0 != memcmp(&dragpoint, &m_ptDrag, sizeof(POINT))) {

					C_WindowDC dc(*this);

					int mode = dc.SetROP2(R2_XORPEN);

					if (m_ptDrag.x != -1 || m_ptDrag.y != -1) {

						dc.CreatePen(PS_SOLID, 2, 0x808080);
						dc.MoveToEx(m_ptDrag.x, m_ptDrag.y);
						dc.LineTo(m_ptDrag.x, m_ptDrag.y + 16);
					}

					m_ptDrag = dragpoint;
					
					if (m_ptDrag.x != -1 || m_ptDrag.y != -1) {

						dc.CreatePen(PS_SOLID, 2, 0x808080);
						dc.MoveToEx(m_ptDrag.x, m_ptDrag.y);
						dc.LineTo(m_ptDrag.x, m_ptDrag.y + 16);
					}
					
					dc.SetROP2(mode);
				}
			}
			else {
				OnDragLeave(uMsg, wParam, lParam, bHandled);
			}
		}
	}
	catch (C_STLNonStackException const &exception) {
		exception.Log(_T("Exception in C_Edit::C_PartialEdit::OnCanDrop"));
	}

	return S_OK;
}
Пример #5
0
void UUserWidget::NativeOnDragLeave( const FDragDropEvent& InDragDropEvent, UDragDropOperation* InOperation )
{
	OnDragLeave( InDragDropEvent, InOperation );
}
Пример #6
0
DROPEFFECT COleDropTarget::OnDragScroll(CWnd* pWnd, DWORD dwKeyState,
	CPoint point)
{
	ASSERT_VALID(this);
	ASSERT_VALID(pWnd);

	// CWnds are allowed, but don't support autoscrolling
	if (!pWnd->IsKindOf(RUNTIME_CLASS(CView)))
		return DROPEFFECT_NONE;
	CView* pView = (CView*)pWnd;
	DROPEFFECT dropEffect = pView->OnDragScroll(dwKeyState, point);

	// DROPEFFECT_SCROLL means do the default
	if (dropEffect != DROPEFFECT_SCROLL)
		return dropEffect;

	// get client rectangle of destination window
	CRect rectClient;
	pWnd->GetClientRect(&rectClient);
	CRect rect = rectClient;

	// hit-test against inset region
	UINT nTimerID = 0xffff;
	rect.InflateRect(-nScrollInset, -nScrollInset);
	CSplitterWnd* pSplitter = NULL;
	if (rectClient.PtInRect(point) && !rect.PtInRect(point))
	{
		// determine which way to scroll along both X & Y axis
		if (point.x < rect.left)
			nTimerID = MAKEWORD(SB_LINEUP, HIBYTE(nTimerID));
		else if (point.x >= rect.right)
			nTimerID = MAKEWORD(SB_LINEDOWN, HIBYTE(nTimerID));
		if (point.y < rect.top)
			nTimerID = MAKEWORD(LOBYTE(nTimerID), SB_LINEUP);
		else if (point.y >= rect.bottom)
			nTimerID = MAKEWORD(LOBYTE(nTimerID), SB_LINEDOWN);
		ASSERT(nTimerID != 0xffff);

		// check for valid scroll first
		pSplitter = CView::GetParentSplitter(pView, FALSE);
		BOOL bEnableScroll = FALSE;
		if (pSplitter != NULL)
			bEnableScroll = pSplitter->DoScroll(pView, nTimerID, FALSE);
		else
			bEnableScroll = pView->OnScroll(nTimerID, 0, FALSE);
		if (!bEnableScroll)
			nTimerID = 0xffff;
	}

	if (nTimerID == 0xffff)
	{
		if (m_nTimerID != 0xffff)
		{
			// send fake OnDragEnter when transition from scroll->normal
			COleDataObject dataObject;
			dataObject.Attach(m_lpDataObject, FALSE);
			OnDragEnter(pWnd, &dataObject, dwKeyState, point);
			m_nTimerID = 0xffff;
		}
		return DROPEFFECT_NONE;
	}

	// save tick count when timer ID changes
	DWORD dwTick = GetTickCount();
	if (nTimerID != m_nTimerID)
	{
		m_dwLastTick = dwTick;
		m_nScrollDelay = nScrollDelay;
	}

	// scroll if necessary
	if (dwTick - m_dwLastTick > m_nScrollDelay)
	{
		if (pSplitter != NULL)
			pSplitter->DoScroll(pView, nTimerID, TRUE);
		else
			pView->OnScroll(nTimerID, 0, TRUE);
		m_dwLastTick = dwTick;
		m_nScrollDelay = nScrollInterval;
	}
	if (m_nTimerID == 0xffff)
	{
		// send fake OnDragLeave when transitioning from normal->scroll
		OnDragLeave(pWnd);
	}

	m_nTimerID = nTimerID;
	// check for force link
	if ((dwKeyState & (MK_CONTROL|MK_SHIFT)) == (MK_CONTROL|MK_SHIFT))
		dropEffect = DROPEFFECT_SCROLL|DROPEFFECT_LINK;
	// check for force copy
	else if ((dwKeyState & MK_CONTROL) == MK_CONTROL)
		dropEffect = DROPEFFECT_SCROLL|DROPEFFECT_COPY;
	// check for force move
	else if ((dwKeyState & MK_ALT) == MK_ALT ||
		(dwKeyState & MK_SHIFT) == MK_SHIFT)
		dropEffect = DROPEFFECT_SCROLL|DROPEFFECT_MOVE;
	// default -- recommended action is move
	else
		dropEffect = DROPEFFECT_SCROLL|DROPEFFECT_MOVE;
	return dropEffect;
}
// Update this later. For now, bail out (via the base class)
DROPEFFECT SECEditCtrlOleDropTarget::OnDragScroll(CWnd* pWnd, DWORD dwKeyState,
	CPoint point)
{
	//return COleDropTarget::OnDragScroll(pWnd, dwKeyState, point);
	ASSERT_VALID(this);
	ASSERT_VALID(pWnd);

	if (!pWnd->IsKindOf(RUNTIME_CLASS(SECEditCtrl)))
		return DROPEFFECT_NONE;

	SECEditCtrl* pSECEditCtrl = (SECEditCtrl*)pWnd;

	DROPEFFECT dropEffect = 0;

	// get client rectangle of destination window
	CRect rectClient;
	pWnd->GetClientRect(&rectClient);
	CRect rect = rectClient;

	// hit-test against inset region
	UINT nTimerID = MAKEWORD(-1, -1);
	rect.InflateRect(-nScrollInset, -nScrollInset);
	if (rectClient.PtInRect(point) && !rect.PtInRect(point))
	{
		// determine which way to scroll along both X & Y axis
		if (point.x < rect.left)
			nTimerID = MAKEWORD(SB_LINEUP, HIBYTE(nTimerID));
		else if (point.x >= rect.right)
			nTimerID = MAKEWORD(SB_LINEDOWN, HIBYTE(nTimerID));
		if (point.y < rect.top)
			nTimerID = MAKEWORD(LOBYTE(nTimerID), SB_LINEUP);
		else if (point.y >= rect.bottom)
			nTimerID = MAKEWORD(LOBYTE(nTimerID), SB_LINEDOWN);
		ASSERT(nTimerID != MAKEWORD(-1, -1));

		BOOL bEnableScroll = FALSE;
		bEnableScroll = pSECEditCtrl->OnScroll(nTimerID, 0, FALSE);

		if (!bEnableScroll)
			nTimerID = MAKEWORD(-1, -1);
	}

	if (nTimerID == MAKEWORD(-1, -1))
	{
		if (m_nTimerID != MAKEWORD(-1, -1))
		{
			// send fake OnDragEnter when transition from scroll->normal
			COleDataObject dataObject;
			dataObject.Attach(m_lpDataObject, FALSE);
			OnDragEnter(pWnd, &dataObject, dwKeyState, point);
			m_nTimerID = MAKEWORD(-1, -1);
		}
		return DROPEFFECT_NONE;
	}

	// save tick count when timer ID changes
	DWORD dwTick = GetTickCount();
	if (nTimerID != m_nTimerID)
	{
		m_dwLastTick = dwTick;
		m_nScrollDelay = nScrollDelay;
	}

	// scroll if necessary
	if (dwTick - m_dwLastTick > m_nScrollDelay)
	{
		pSECEditCtrl->OnScroll(nTimerID, 0, TRUE);
		m_dwLastTick = dwTick;
		m_nScrollDelay = nScrollInterval;
	}
	if (m_nTimerID == MAKEWORD(-1, -1))
	{
		// send fake OnDragLeave when transitioning from normal->scroll
		OnDragLeave(pWnd);
	}

	m_nTimerID = nTimerID;
	// check for force link
	if ((dwKeyState & (MK_CONTROL|MK_SHIFT)) == (MK_CONTROL|MK_SHIFT))
		dropEffect = DROPEFFECT_SCROLL|DROPEFFECT_LINK;
	// check for force copy
	else if ((dwKeyState & MK_CONTROL) == MK_CONTROL)
		dropEffect = DROPEFFECT_SCROLL|DROPEFFECT_COPY;
	// check for force move
	else if ((dwKeyState & MK_ALT) == MK_ALT ||
		(dwKeyState & MK_SHIFT) == MK_SHIFT)
		dropEffect = DROPEFFECT_SCROLL|DROPEFFECT_MOVE;
	// default -- recommended action is move
	else
		dropEffect = DROPEFFECT_SCROLL|DROPEFFECT_MOVE;
	return dropEffect;
}