Partager via


IXRHitTestResults (Windows Embedded CE 6.0)

1/6/2010

This class contains information about the UI objects affected during a hit test.

This class supports the methods on the IUnknown interface.

Syntax

class IXRHitTestResults : public IUnknown

Methods

Method Description

IXRHitTestResults::GetCount

Retrieves the number of items in this hit-test results object.

IXRHitTestResults::GetItem

Retrieves the item at the specified index in this hit-test results object.

Remarks

IXRHitTestResults provides information about the results of a hit test. Hit testing is the process by which Silverlight takes the input stimulus (such as mouse clicks) from the application, and then determines which IXRUIElement object in the layout and visual tree to designate as the source of the input event.

Do not create a new IXRHitTestResults object. To retrieve this object, call IXRUIElement::HitTest.

Note

UI objects that can be used for hit testing must return true when IXRUIElement::GetIsHitTestVisible is called.

If the value retrieved by IXRHitTestResults::GetCount is greater than 0 (zero), you can iterate through the objects by calling IXRHitTestResults::GetItem for each iteration to retrieve a pointer to each affected object.

Example

The following example code conducts a hit test for an IXRUIElement object and captures the results in an IXRHitTestResults object.

Important

For readability, the following code example does not contain security checking or error handling. Do not use the following code in a production environment.

#include <windows.h>
#include <XamlRuntime.h>
#include <XRPtr.h>


void GetAffectedObjects(IXRUIElement* pUIElement, XRRect* rect)
{
  // Perform a hit test and retrieve hit-test results

  IXRHitTestResults* pAffectedElements;
  pUIElement->HitTest(rect, &pAffectedElements);

   // Get the count of elements affected by the hit test

  int count = 0;
  pAffectedElements->GetCount(&count);

  // Retrieve the name of each affected object

  IXRUIElementPtr pMyElement;
  WCHAR* szObjName;

  for (int i = 0;i<count; i++)
  {
    pAffectedElements->GetItem(i, &pMyElement);
    pMyElement->GetName(&szObjName); 
        
    
  }
}

To run the previous code example, both an IXRUIElement-derived object and an XRRect structure must both be created, and the IXRUIElement-derived object must be visible for hit testing and in the visual tree.

.NET Framework Equivalent

None.

Requirements

Header XamlRuntime.h
sysgen SYSGEN_XAML_RUNTIME
Windows Embedded CE Windows Embedded CE 6.0 R3

See Also

Reference

Classes for UI Element Management