Пример #1
0
BOOL CXTPMouseManager::PreTranslateMouseEvents(WPARAM wParam, POINT point)
{
	HWND hWndMouse = ::WindowFromPoint(point);
	CTrackArray& arrTracked = m_arrTracked;
	int i;

	for (i = (int)arrTracked.GetSize() - 1; i >= 0; i--)
	{
		CXTPCommandBar* pCommandBar = arrTracked[i];

		if (!pCommandBar->GetSafeHwnd())
			continue;

		int nHtCode = pCommandBar->OnMouseHitTest(point);

		if ((nHtCode != HTERROR) && ((nHtCode == HTCLIENT) || ::IsChild(pCommandBar->GetSafeHwnd(), hWndMouse) || IsRelated(pCommandBar->GetSafeHwnd(), hWndMouse)))
		{
			if (pCommandBar->m_nLockRecurse > 0 && wParam != WM_MOUSEMOVE && wParam != WM_NCMOUSEMOVE && !m_bIgnoreLButtonUp)
			{
				SendTrackLostRecurse();
				ptMouse = 0;
			}
			return FALSE;
		}
	}

	if (arrTracked.GetSize() > 0)
	{
		CTrustedArray& arrTrusted = m_arrTrusted;
		for (i = 0; i < arrTrusted.GetSize(); i++)
		{
			HWND hWnd = arrTrusted[i];
			if (IsWindow(hWnd) && IsWindowVisible(hWnd) && CXTPWindowRect(hWnd).PtInRect(point))
			{
				return FALSE;
			}
		}

	}

	if (hWndMouse && arrTracked.GetSize() > 0)
	{
		if (GetClassLong(hWndMouse, GCL_STYLE) & CS_IME)
			return FALSE;
	}

	for (i = 0; i < arrTracked.GetSize(); i++)
	{
		DeliverMessage(arrTracked.GetAt(i), wParam, point);
	}

	return FALSE;

}
// picks the current target
void CXTPCustomizeDropSource::PickTarget(CPoint point)
{
	HWND hWndPoint = WindowFromPoint(point);

	BOOL bFound = FALSE;

	for (int i = (int)m_arrTargets.GetSize() - 1; i >= 0; i--)
	{
		CXTPCommandBar* pCommandBar = m_arrTargets[i];

		if (pCommandBar->IsVisible() && CXTPWindowRect(pCommandBar).PtInRect(point)
			&& (pCommandBar->GetSafeHwnd() == hWndPoint || ::IsChild(pCommandBar->GetSafeHwnd(), hWndPoint)))
		{
			bFound = TRUE;

			if (m_pTarget == pCommandBar)
			{
				m_pTarget->ScreenToClient(&point);
				m_pTarget->OnCustomizeDragOver(m_pControl, point);
			}
			else if (m_pTarget != NULL)
			{
				m_pTarget->OnCustomizeDragLeave();
				m_pTarget = 0;
			}

			if (m_pTarget == 0)
			{
				pCommandBar->ScreenToClient(&point);
				if (pCommandBar->OnCustomizeDragEnter(m_pControl, point) != DROPEFFECT_NONE)
				{
					m_pTarget = pCommandBar;
				}
			}
			break;
		}
	}

	if (!bFound && m_pTarget)
	{
		m_pTarget->OnCustomizeDragLeave();
		m_pTarget = 0;
	}


	// set the cursor as appropriate
	FreshenCursor();
}
Пример #3
0
CXTPCommandBar* CXTPMouseManager::HitTest(POINT point) const
{
	HWND hWndMouse = ::WindowFromPoint(point);
	const CTrackArray& arrTracked = m_arrTracked;
	int i;

	for (i = (int)arrTracked.GetSize() - 1; i >= 0; i--)
	{
		CXTPCommandBar* pCommandBar = arrTracked[i];

		if (!pCommandBar->GetSafeHwnd())
			continue;

		int nHtCode = pCommandBar->OnMouseHitTest(point);

		if ((nHtCode != HTERROR) && ((nHtCode == HTCLIENT) || ::IsChild(pCommandBar->GetSafeHwnd(), hWndMouse)))
		{
			return pCommandBar;
		}
	}

	return NULL;
}