次の方法で共有


IViewObjectEx::QueryHitPoint (Windows Embedded CE 6.0)

1/6/2010

This method indicates whether a point is within a given aspect of an object.

Syntax

HRESULT QueryHitPoint(
  DWORD dwAspect,
  LPRECT pRectBounds,
  POINTL ptlLoc,
  LONG lCloseHint,
  DWORD* pHitResult
);

Parameters

  • dwAspect
    [in] Requested drawing aspect.
  • pRectBounds
    [in] Object bounding rectangle in client coordinates of the containing window. This rectangle is computed and passed by the container so that the object can meaningfully interpret the hit location.
  • ptlLoc
    [in] Hit location in client coordinates of the containing window.
  • lCloseHint
    [in] Suggested distance in HIMETRIC units that the container considers close. This value is a hint, and objects can interpret it in their own way. Objects can also use this hint to roughly infer output resolution to choose the expansiveness of hit test implementation.
  • pHitResult
    [out] Pointer to returned information about the hit expressed as the HITRESULT enumeration values.

Return Value

If the method returns S_OK, the hit information was successfully returned in pHitResult.

If E_FAIL is returned, this method is not implemented for the requested aspect. Use DVASPECT_CONTENT instead.

Remarks

To support hit detection on non-rectangular objects, the container needs a reliable way to ask an object whether a given location is inside one of its drawing aspects. This function is provided by IViewObjectEx::QueryHitPoint.

Because this method is part of the IViewObjectEx interface, the container can figure whether a mouse hit is over an object without having to necessarily launch the server.

If the hit happens to be inside the object, it is likely that the object will be in-place activated and the server started.

Typically, the container first quickly determines whether a given location is within the rectangular extent of an object.

If the location is within the rectangular extent of an object, the container calls IViewObjectEx::QueryHitPoint to get confirmation that the location is actually inside the object.

The hit location is passed in client coordinates of the container window. Because the object may be inactive when this method is called, the bounding rectangle of the object in the same coordinate system is also passed to this method, similarly to what happens in IPointerInactive::OnInactiveSetCursor.

Possible returned values include the following:

  • Outside, on a transparent region
  • Close enough to be considered a hit (which may be used by small or thin objects)
  • Hit

QueryHitPoint is not concerned by the subobjects of the object it is called for. It merely indicates whether the mouse hit was within the object.

QueryHitPoint can be called for any of the drawing aspects an object supports. It should fail if it is not supported for the requested drawing aspect.

Transparent objects may want to implement a complex hit-detection mechanism where the user can select either the transparent object or an object behind it, depending on where exactly the click happens inside the object.

For example, a transparent TextBox showing big enough text may let the user select the object behind, for example, a bitmap, when the user clicks between the characters.

For this reason, the information returned by QueryHitPoint includes indication about whether the hit happens on an opaque or transparent region.

The following illustration shows a transparent circle control with an object behind it.

Ee488989.f1c52dae-c597-45c7-a9af-b13414781da0(en-US,WinEmbedded.60).gif

The values shown are for hit tests against the circle; olive green regions are not part of the control, but they are shown to indicate an area around the image considered close.

Each object implements its own definition of close but is assisted by a hint provided by the container so that closeness can be adjusted as images zoom larger or smaller.

In the previous illustration, the points marked Hit, Close, and Transparent would all be hits of varying strength on the circle, with the exception of the one marked Transparent, (but for the line, close).

This illustrates the effect of the different strength of hits. Because the circle responds transparent while the line claims close, and transparent is weaker than close, the line takes the hit.

To determine whether the platform supports this interface, see Determining Supported COM APIs.

Ee488989.collapse(en-US,WinEmbedded.60).gifNote to Implementers

An object supporting IViewObjectEx is required to implement this method at least for the DVASPECT_CONTENT aspect. The object should not take any other action in response to this method other than to return the information; there should be no side effects.

Requirements

Header ocidl.h, ocidl.idl
Library ole32.lib, uuid.lib
Windows Embedded CE Windows CE 3.0 and later

See Also

Reference

IViewObjectEx
HITRESULT