本文整理汇总了C++中UIElement::RaiseEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ UIElement::RaiseEvent方法的具体用法?C++ UIElement::RaiseEvent怎么用?C++ UIElement::RaiseEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIElement
的用法示例。
在下文中一共展示了UIElement::RaiseEvent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnMouseButtonDown
void PlatformWindowSite::OnMouseButtonDown(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);
args->m_screenpos = Point(float(screenMousePos.x), float(screenMousePos.y));
args->m_clientpos = clientMousePos;
// Raise general mousedown event
args->set_RoutedEvent(UIElement::get_MouseButtonDownEvent());
hitElement->RaiseEvent(args);
// Raise button mousedown event
if (button == 0) args->set_RoutedEvent(UIElement::get_MouseLeftButtonDownEvent());
else if (button == 1) args->set_RoutedEvent(UIElement::get_MouseMiddleButtonDownEvent());
else args->set_RoutedEvent(UIElement::get_MouseRightButtonDownEvent());
hitElement->RaiseEvent(args);
}
}
示例2: OnMouseButtonUp
void PlatformWindowSite::OnMouseButtonUp(gm::PointF clientMousePos, int button)
{
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);
}
hitElement = child;
}
if (hitElement)
{
MouseButtonEventArgs* args = new MouseButtonEventArgs(nullptr, 0);
if (button == 0) args->set_RoutedEvent(UIElement::get_MouseLeftButtonUpEvent());
else if (button == 1) args->set_RoutedEvent(UIElement::get_MouseMiddleButtonUpEvent());
else args->set_RoutedEvent(UIElement::get_MouseRightButtonUpEvent());
args->m_screenpos = Point(float(screenMousePos.x), float(screenMousePos.y));
args->m_clientpos = clientMousePos;
hitElement->RaiseEvent(args);
}
}
示例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: 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;
}