AnnDefine2 example for Visual Basic
'This example uses static variables to simulate user input to
'rotate/resize a rectangle around a point on the bottom center line of the rectangle.
'Intially the rectangle must not be rotated.
Private Sub ExampleAnnDefine2(hRect As Long)
Dim hContainer As Long
Dim ObjectType As AnnObjectType
Dim Angle As Double
Dim CallCount As Long
Dim RectTop As Double
Dim RectLeft As Double
Dim RectWidth As Double
Dim RectHeight As Double
Dim RectRight As Double
Dim RectBottom As Double
Dim AnchorX As Double
Dim AnchorY As Double
Dim MoveX As Double
Dim MoveY As Double
Dim AnnPointX As Double
Dim AnnPointY As Double
RasterAnn.AnnGetType hObject
ObjectType = RasterAnn.AnnType
If ObjectType <> ANN_OBJECT_RECT Then
MsgBox "This Object is not Rect Object"
End If
Angle = RasterAnn.AnnRotateAngle(hRect)
If Angle <> 0 Then
MsgBox "Object must not be rotated"
End If
CallCount = CallCount + 1
Select Case CallCount
Case 1
RectTop = RasterAnn.AnnRectTop(hObject)
RectLeft = RasterAnn.AnnRectLeft(hObject)
RectWidth = RasterAnn.AnnRectWidth(hObject)
RectHeight = RasterAnn.AnnRectHeight(hObject)
RectRight = RectWidth + RectLeft
RectBottom = RectHeight + RectTop
AnchorX = (RectLeft + RectRight) / 2
AnchorY = RectBottom
AnnPointX = (RectLeft + RectRight) / 2
AnnPointY = RectTop
RasterAnn.AnnDefine2 hRect, AnchorX, AnchorY, ANN_DEFINE_SETANCHORPOINT
RasterAnn.AnnDefine2 hRect, AnnPointX, AnnPointY, ANN_DEFINE_BEGINMOVEPOINT
Case 2
RectTop = RasterAnn.AnnRectTop(hObject)
RectLeft = RasterAnn.AnnRectLeft(hObject)
RectWidth = RasterAnn.AnnRectWidth(hObject)
RectHeight = RasterAnn.AnnRectHeight(hObject)
RectRight = RectWidth + RectLeft
RectBottom = RectHeight + RectTop
RasterAnn.PointsCount = 1
RasterAnn.ContainerPointX = RectRight
RasterAnn.ContainerPointY = RectTop
hContainer = RasterAnn.AnnGetContainer(hRect)
RasterAnn.AnnConvert hContainer, ANN_CONVERT_TO_CLIENT
RasterAnn.PointIndex = 0
MoveX = RasterAnn.ClientPointX
MoveY = RasterAnn.ClientPointY
RasterAnn.AnnDefine2 hRect, MoveX, MoveY, ANN_DEFINE_END
CallCount = 0
End Select
End Sub