Partager via


IXRUIElement::CaptureMouse (Compact 2013)

3/28/2014

This method enables the UI element to capture the mouse.

Syntax

virtual HRESULT STDMETHODCALLTYPE CaptureMouse(
    bool* pValue
) = 0;

Parameters

  • pValue
    [out] Boolean value that returns true if the element has enabled mouse capture; otherwise, it returns false.

Return Value

Returns an HRESULT that indicates success or failure.

Remarks

When an element has captured the mouse, it receives mouse input whether or not the pointer is within its bounding area on the graphical window. The mouse is typically only captured during simulated drag operations. To release mouse capture by an object, use the IXRUIElement::ReleaseMouseCapture method.

The mouse can be captured when all the following conditions are true:

  • The mouse pointer is over the graphical window that belongs to XAML for Windows Embedded.
  • No other XAML for Windows Embedded object has captured the mouse.
  • No other non-XAML for Windows Embedded object has captured the mouse from native code or scripting code.
  • The left mouse button is in a pressed (down) state.

If one of these conditions is false, the CaptureMouse method returns false in pValue.

If an initial CaptureMouse call returned true and successfully captured the mouse, successive calls to CaptureMouse on the same object will still return true unless conditions have changed; CaptureMouse returns nothing different if that object already has capture. Depending on the requirements of your application, you might find it useful to set a variable that either tracks whether any object holds capture, or provides a reference to the specific object that currently has capture. If you used this technique, you would set the variable on each CaptureMouse call and clear it on each IXRUIElement::ReleaseMouseCapture call.

Only a IXRUIElement derived object can capture the mouse.

.NET Framework Equivalent

System.Windows.UIElement.CaptureMouse

Requirements

Header

XamlRuntime.h

sysgen

SYSGEN_XAML_RUNTIME

See Also

Reference

IXRUIElement
IXRUIElement::ReleaseMouseCapture