本文整理汇总了C++中UIElement::HitTest_方法的典型用法代码示例。如果您正苦于以下问题:C++ UIElement::HitTest_方法的具体用法?C++ UIElement::HitTest_怎么用?C++ UIElement::HitTest_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIElement
的用法示例。
在下文中一共展示了UIElement::HitTest_方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnMouseButtonDblClk
void PlatformWindowSite::OnMouseButtonDblClk(gm::PointF clientMousePos, int button)
{
POINT screenMousePos;
::GetCursorPos(&screenMousePos);
UIElement* hitElement = nullptr;
UIElement* child = GetRootElement();
// Visual* child = get_Child();
if (child)
{
hitElement = child->HitTest_(clientMousePos);
}
// hitElement = child;
if (hitElement)
{
MouseButtonEventArgs* args = new MouseButtonEventArgs(nullptr, 0);
if (button == 0) args->set_RoutedEvent(UIElement::get_MouseLeftButtonDoubleClickEvent());
else if (button == 1) args->set_RoutedEvent(UIElement::get_MouseMiddleButtonDoubleClickEvent());
else args->set_RoutedEvent(UIElement::get_MouseRightButtonDoubleClickEvent());
args->m_screenpos = Point(float(screenMousePos.x), float(screenMousePos.y));
args->m_clientpos = clientMousePos;
hitElement->RaiseEvent(args);
}
}
示例2: DragOver
HRESULT PlatformWindowSite::DragOver(
/* [in] */ DWORD grfKeyState,
/* [in] */ POINTL pt,
/* [out][in] */ __RPC__inout DWORD *pdwEffect)
{
Point screenMousePos(pt.x, pt.y);
ScreenToClient(m_platformWindow->get_Handle(), (POINT*)&pt);
Point clientMousePos(pt.x, pt.y);
if (m_DragOverElement)
{
DragEventArgs* args = new DragEventArgs(m_pDataObject);
args->set_RoutedEvent(UIElement::get_DragLeaveEvent());
// args->m_screenpos = Point(float(screenMousePos.x), float(screenMousePos.y));
// args->m_clientpos = clientMousePos;
m_DragOverElement->RaiseEvent(args);
}
UIElement* child = GetRootElement();
if (child)
{
m_DragOverElement = child->HitTest_(clientMousePos);
}
if (m_DragOverElement == nullptr)
{
m_DragOverElement = GetRootWindow();
}
if (m_DragOverElement)
{
DragEventArgs* args = new DragEventArgs(m_pDataObject);
args->set_RoutedEvent(UIElement::get_DragEnterEvent());
// args->m_screenpos = Point(float(screenMousePos.x), float(screenMousePos.y));
// args->m_clientpos = clientMousePos;
m_DragOverElement->RaiseEvent(args);
}
// Call IDragImages::DragEnter last
m_dropTargetHelper->DragOver((POINT*)&pt, *pdwEffect);
return S_OK;
}
示例3: OnMouseMove
void PlatformWindowSite::OnMouseMove(gm::PointF clientMousePos)
{
POINT screenMousePos;
::GetCursorPos(&screenMousePos);
UIElement* hitElement = nullptr;
if (m_MouseCaptureElement)
{
hitElement = m_MouseCaptureElement;
}
else
{
//Visual* child = get_Child();
UIElement* child = GetRootElement();
if (child)
{
hitElement = child->HitTest_(clientMousePos);
}
}
if (m_MouseOverElement != hitElement)
{
// Find common ancestor
UIElement* commonAncestor = m_MouseOverElement->FindCommonAncestor(hitElement);
// ASSERT(commonAncestor);
for (UIElement* p = m_MouseOverElement; p != commonAncestor; p = p->get_Parent())
{
p->set_IsMouseOver(false);
}
for (UIElement* p = hitElement; p != commonAncestor; p = p->get_Parent())
{
p->set_IsMouseOver(true);
}
if (m_MouseOverElement)
{
m_MouseOverElement->set_IsMouseDirectlyOver(false);
}
m_MouseOverElement = hitElement;
if (m_MouseOverElement)
{
m_MouseOverElement->set_IsMouseDirectlyOver(true);
}
}
if (hitElement)
{
MouseEventArgs* args = new MouseEventArgs(nullptr, 0);
args->set_RoutedEvent(UIElement::get_MouseMoveEvent());
args->m_screenpos = Point(float(screenMousePos.x), float(screenMousePos.y));
args->m_clientpos = clientMousePos;
hitElement->RaiseEvent(args);
}
}
示例4: OnSetCursor
bool PlatformWindowSite::OnSetCursor(UINT hitTest, POINT screenMousePos)
{
if (hitTest == HTCLIENT)
{
gm::PointF clientMousePos(screenMousePos.x, screenMousePos.y);
ScreenToClient(m_platformWindow->get_Handle(), (POINT*)&clientMousePos);
IInputElement* hitElement = nullptr;
if (m_MouseCaptureElement)
{
hitElement = m_MouseCaptureElement;
}
else
{
//Visual* child = get_Child();
UIElement* child = GetRootElement();
if (child)
{
hitElement = child->HitTest_(clientMousePos);
}
// hitElement = child;
}
if (hitElement == nullptr)
{
hitElement = dynamic_cast<IInputElement*>(this);
}
if (hitElement)
{
/*
MouseEventArgs* args = new MouseEventArgs(nullptr, 0);
args->set_RoutedEvent(UIElement::MouseMoveEvent);
args->m_screenpos = Point(float(screenMousePos.x), float(screenMousePos.y));
args->m_clientpos = clientMousePos;
hitElement->RaiseEvent(args);
*/
Cursor* pCursor = dynamic_cast<UIElement*>(hitElement)->get_Cursor();
if (pCursor)
{
SetCursor(pCursor->GetHCursor());
if (!showCursor)
{
showCursor = true;
::ShowCursor(TRUE);
}
return true;
}
else
{
if (showCursor)
{
showCursor = false;
::ShowCursor(FALSE);
}
}
}
}
return false;
}
示例5: DragEnter
HRESULT PlatformWindowSite::DragEnter(
::IDataObject* pDataObject,
/* [in] */ DWORD grfKeyState,
/* [in] */ POINTL pt,
/* [out][in] */ __RPC__inout DWORD *pdwEffect)
{
m_pDataObject = pDataObject;
/*
if (m_pDataObject != pDataObject)
{
m_pDataObject = pDataObject;
m_dataObject = new DataObject;
m_dataObject->m_pDataObject = m_pDataObject;
}*/
if (m_dropTargetHelper == nullptr)
{
HRESULT hr;
hr = m_dropTargetHelper.CoCreateInstance(CLSID_DragDropHelper);
if (FAILED(hr)) return hr;
}
// ComPtr<IEnumFORMATETC> enumfmt;
// pDataObject->EnumFormatEtc(DATADIR_GET, &enumfmt);
/*
FORMATETC fetc;
DWORD fetched;
while ((enumfmt->Next(1, &fetc, &fetched) == S_OK) && fetched)
{
DebugTrace("Format " << fetc.cfFormat << "\n");
//CF_TEXT
}
*/
UIElement* hitElement = nullptr;
gm::PointF screenMousePos(float(pt.x), float(pt.y));
ScreenToClient(m_platformWindow->get_Handle(), (POINT*)&pt);
Point clientMousePos(pt.x, pt.y);
UIElement* child = GetRootElement();
if (child)
{
hitElement = child->HitTest_(clientMousePos);
}
if (hitElement == nullptr)
{
hitElement = GetRootWindow();
}
if (hitElement)
{
m_DragOverElement = hitElement;
DragEventArgs* args = new DragEventArgs(pDataObject);
args->set_RoutedEvent(UIElement::get_DragEnterEvent());
// args->m_screenpos = Point(float(screenMousePos.x), float(screenMousePos.y));
// args->m_clientpos = clientMousePos;
hitElement->RaiseEvent(args);
}
// Call IDragImages::DragEnter last
m_dropTargetHelper->DragEnter(m_platformWindow->get_Handle(), pDataObject, (POINT*)&pt, *pdwEffect);
return S_OK;
}