AnnRestrictCursor example for C++ 5 and later
//'Example for AnnConvert, AnnRestrictCursor
//'This example restricts the cursor to 10 pixels on either side
//'of the bounding box of the annotation object. For example,
//'if the object is a rectangle, the mouse cursor will be restricted
//'to an area that is 10 pixels larger than the rectangle
void CTutorDlg::ExampleAnnRestrictCursor(long hObject)
{
long hContainer;
AnnObjectType ObjectType;
double BoundsTop;
double BoundsLeft;
double BoundsWidth;
double BoundsHeight;
double BoundsRight ;
double BoundsBottom ;
double OldClipTop ;
double OldClipLeft ;
double OldClipRight ;
double OldClipBottom;
m_pRasterAnn->AnnGetType(hObject);
ObjectType = m_pRasterAnn->GetAnnType();
if(( ObjectType != ANN_OBJECT_AUTOMATION) && (ObjectType != ANN_OBJECT_CONTAINER) )
MessageBox(TEXT("This object is not an Automation Object and it is not a Container Object"));
hContainer = m_pRasterAnn->AnnGetTopContainer(hObject);
BoundsTop = m_pRasterAnn->GetAnnRectTop(hObject);
BoundsLeft = m_pRasterAnn->GetAnnRectLeft(hObject);
BoundsWidth = m_pRasterAnn->GetAnnRectWidth(hObject);
BoundsHeight = m_pRasterAnn->GetAnnRectHeight(hObject);
m_pRasterAnn->PointsCount = 2;
m_pRasterAnn->ContainerPointX = BoundsLeft;
m_pRasterAnn->ContainerPointY = BoundsTop;
m_pRasterAnn->AnnConvert(hObject, ANN_CONVERT_TO_CLIENT);
m_pRasterAnn->PointIndex = 0;
BoundsLeft = m_pRasterAnn->ClientPointX;
BoundsTop = m_pRasterAnn->ClientPointY;
BoundsRight = (BoundsWidth + BoundsLeft) + 10;
BoundsBottom = (BoundsHeight + BoundsTop) + 10;
BoundsTop = BoundsTop - 10;
BoundsLeft = BoundsLeft - 10;
m_pRasterAnn->AnnRestrictCursor(hContainer, (long)BoundsLeft, (long)BoundsTop, (long)BoundsRight, (long)BoundsBottom, 0, 0, FALSE);
OldClipTop = m_pRasterAnn->TopPreviousClip;
OldClipLeft = m_pRasterAnn->LeftPreviousClip;
OldClipRight = m_pRasterAnn->RightPreviousClip;
OldClipBottom = m_pRasterAnn->BottomPreviousClip;
//'When done with restricting cursor, call the line below
//ClipCursor
}