IViewObjectEx::QueryHitPoint method (ocidl.h)
Indicates whether a point is within a given aspect of an object.
Syntax
HRESULT QueryHitPoint(
[in] DWORD dwAspect,
[in] LPCRECT pRectBounds,
[in] POINT ptlLoc,
[in] LONG lCloseHint,
[out] DWORD *pHitResult
);
Parameters
[in] dwAspect
The requested drawing aspect.
[in] pRectBounds
An 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.
[in] ptlLoc
The hit location in client coordinates of the containing window.
[in] lCloseHint
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 expansiveness of hit test implementation.
[out] pHitResult
A pointer to returned information about the hit expressed as the HITRESULT enumeration values.
Return value
This method returns S_OK on success. Other possible return values include the following.
Return code | Description |
---|---|
|
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.
Possible returned values include:
- Outside, on a transparent region
- Close enough to be considered a hit (may be used by small or thin objects)
- Hit
IViewObjectEx::QueryHitPoint can be called for any of the drawing aspects an object supports. It should fail if the it is not supported for the requested drawing aspect.
Transparent objects may wish 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 text box 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 IViewObjectEx::QueryHitPoint includes indication about whether the hit happens on an opaque or transparent region.
An example of non-rectangular and transparent hit detection is a transparent circle control with an object behind it (a line in the example below):
The values shown are for hit tests against the circle; gray regions are not part of the control, but are shown here 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 picture above, 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.
Notes 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
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | ocidl.h |