AnnRestrictCursor example for Visual Basic
'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
Private Sub ExampleAnnRestrictCursor(hObject As Long)
Dim hContainer As Long
Dim ObjectType As AnnObjectType
Dim BoundsTop As Double
Dim BoundsLeft As Double
Dim BoundsWidth As Double
Dim BoundsHeight As Double
Dim BoundsRight As Double
Dim BoundsBottom As Double
Dim OldClipTop As Double
Dim OldClipLeft As Double
Dim OldClipRight As Double
Dim OldClipBottom As Double
RasterAnn.AnnGetType hObject
ObjectType = RasterAnn.AnnType
'If (ObjectType <> ANN_OBJECT_AUTOMATION) And (ObjectType <> ANN_OBJECT_CONTAINER) Then
'MsgBox "This object is not an Automation Object and it is not a Container Object."
'End If
hContainer = RasterAnn.AnnGetTopContainer(hObject)
BoundsTop = RasterAnn.AnnRectTop(hObject)
BoundsLeft = RasterAnn.AnnRectLeft(hObject)
BoundsWidth = RasterAnn.AnnRectWidth(hObject)
BoundsHeight = RasterAnn.AnnRectHeight(hObject)
RasterAnn.PointsCount = 2
RasterAnn.ContainerPointX = BoundsLeft
RasterAnn.ContainerPointY = BoundsTop
RasterAnn.AnnConvert hObject, ANN_CONVERT_TO_CLIENT
RasterAnn.PointIndex = 0
BoundsLeft = RasterAnn.ClientPointX
BoundsTop = RasterAnn.ClientPointY
BoundsRight = (BoundsWidth + BoundsLeft) + 10
BoundsBottom = (BoundsHeight + BoundsTop) + 10
BoundsTop = BoundsTop - 10
BoundsLeft = BoundsLeft - 10
RasterAnn.AnnRestrictCursor hContainer, BoundsLeft, BoundsTop, BoundsRight, BoundsBottom, 0, 0, False
OldClipTop = RasterAnn.TopPreviousClip
OldClipLeft = RasterAnn.LeftPreviousClip
OldClipRight = RasterAnn.RightPreviousClip
OldClipBottom = RasterAnn.BottomPreviousClip
'When done with restricting cursor, call the line below
'ClipCursor
End Sub