LAnnContainer::HitTestExt

#include "ltwrappr.h"

virtual LAnnotation L_FAR * LAnnContainer::HitTestExt(pPoint, puResult, pHitTestInfo, uStructSize)

virtual L_INT LAnnContainer::HitTestExt(pPoint, puResult, phObjectHit, pHitTestInfo, uStructSize)

LPPOINT pPoint;

/* pointer to a structure */

L_UINT L_FAR * puResult;

/* position on the object at the point */

pHANNOBJECT phObjectHit;

/* address of the variable to be updated */

pHITTESTINFO pHitTestInfo;

/* pointer to a structure that provides hit test information */

L_UINT uStructSize;

/* size in bytes, of the structure pointed to by pHitTestInfo */

This function encapsulates LAnnContainer::HitTest, which gets the handle to the annotation object that is located at a specified point. (If objects overlap, it gets the front object.)

LAnnContainer::HitTestExt provides additional information about the annotation object handle if the handle is a default or user-defined handle.This function is available in the Document/Medical Toolkits.

Parameter

Description

pPoint

Pointer to the POINT structure that specifies the point to test. Coordinates are relative to the associated window's client area.

puResult

The position on the annotation object that was found at the specified point. Possible values are:

 

ANNHIT_NONE [0]

 

ANNHIT_BODY [1]

 

ANNHIT_HANDLE [2]

 

ANNHIT_NAME [3]

 

ANNHIT_USER_HANDLE [4]

 

ANNHIT_ROTATE_HANDLE [5]

 

ANNHIT_MULTISELECT_HANDLE [6]

 

ANNHIT_MULTISELECT_ROTATE_HANDLE [7]

 

ANNHIT_MULTISELECT_BODY [8]

 

If (*puResult) is updated with ANNHIT_HANDLE or ANNHIT_USER_HANDLE, then pHitTestInfo contains additional information about the annotation object handle. For example, if (*puResult) is ANNHIT_ROTATE_HANDLE, pHitTestInfo->nHandleID will be either ROTATE_HANDLE_CENTER_ID [100] or ROTATE_HANDLE_GRIPPER_ID [101] to identify which rotate handle was hit.

phObjectHit

Address of the variable to be updated with the handle to the annotation object that is found at the specified point.

pHitTestInfo

Pointer to a HITTESTINFO structure that provides hit test information whenever (*puResult) is updated with ANNHIT_HANDLE or ANNHIT_USER_HANDLE.

uStructSize

Size in bytes, of the structure pointed to by pHitTestInfo, for versioning. Use sizeof(HITTESTINFO).

Returns

LAnnContainer::HitTestExt(pPoint, puResult, phObjectHit, pHitTestInfo, uStructSize) returns the following:

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

LAnnContainer::HitTestExt(pPoint, puResult, pHitTestInfo, uStructSize) returns the following:

A pointer to the annotation object that is located at the specified point. The user is responsible for deleting the returned object.

Comments

Before calling this function, you must declare a variable of data type HANNOBJECT. You can then pass the address of the variable in the phObjectHit parameter, which this function will update with the handle of the object located at the specified point.

Required DLLs and Libraries

LTANN

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

LAnnContainer::HitTest, Class Members, LAnnotation::GetRotateOptions, LAnnotation::SetRotateOptions

Topics:

Annotation Functions: Using Window Coordinates to Select Objects

 

Annotation Functions: Object Information

Example

// This example uses the caller's mouse coordinates to get the handle
// to the annotation object at the specified coordinates.
// The part of the clicked annotation is displayed in the Output window.
// If the result of the hit test is a user handle, additional information about the handle is displayed.
L_VOID ExampleAnnHitTestExt(LAnnContainer *pLContainer, POINT ptPointToTest, pHANNOBJECT phAnnObject)
{
   L_TCHAR szMsg[200];
   L_TCHAR szHitTestInfo[200];
   ANNHITTESTINFO HitTestInfo;
   L_TCHAR *pszResult;
   L_INT nRet;

   // This function determines which annotation object you have clicked.
   HANNOBJECT hObject; // Local variable for the annotation object
   L_UINT uResult; // Result of the test

   // Get the object at the specified point
   memset(&HitTestInfo, 0, sizeof(ANNHITTESTINFO));
   HitTestInfo.uStructSize = sizeof(ANNHITTESTINFO);
   nRet = pLContainer->HitTestExt(&ptPointToTest, &uResult, &hObject, &HitTestInfo, sizeof(HitTestInfo));
   if (nRet != SUCCESS)
      return;

   switch(uResult)
   {
      case ANNHIT_NONE:
         pszResult = TEXT("ANNHIT_NONE");
      break;

      case ANNHIT_BODY:
         pszResult = TEXT("ANNHIT_BODY");
      break;

      case ANNHIT_NAME:
         pszResult = TEXT("ANNHIT_NAME");
      break;

      case ANNHIT_HANDLE:
         wsprintf(szHitTestInfo, TEXT("ANNHIT_HANDLE nHandleIndex[%d], nHandleID[%d]"),
HitTestInfo.nHandleIndex, HitTestInfo.nHandleID);
         pszResult = szHitTestInfo;
      break;

      case ANNHIT_USER_HANDLE:
         wsprintf(szHitTestInfo, TEXT("ANNHIT_USER_HANDLE nHandleIndex[%d], nHandleID[%d]"),
HitTestInfo.nHandleIndex, HitTestInfo.nHandleID);
         pszResult = szHitTestInfo;
      break;
   }

   wsprintf(szMsg, TEXT("[%x] %s\n"), hObject, pszResult);
   OutputDebugString(szMsg);
   return;
}