AnnCalibrateRuler Example for Visual Basic
' The following example calibrates a ruler object (hObject)
' so that it measures 10 inches with a DPI ratio of 1:1 and
' then sets this calibration to ALL ruler objects
' (ANN_OBJECT_RULER, ANN_OBJECT_POLYRULER, ANN_OBJECT_CROSSPRODUCT, ANN_OBJECT_PROTRACTOR)
' in the container:
Private Sub ExampleAnnCalibrateRuler_Click()
Dim nRet As Integer
Dim lObjectType As Long
Dim dDpiX As Double
Dim dDpiY As Double
Dim hObjectRuler As Long
nRet = RasterAnn.AnnCreate(ANN_OBJECT_RULER, True, True)
hObjectRuler = RasterAnn.AnnObject
RasterAnn.AnnDefine hObjectRuler, 0, 0, ANN_DEFINE_BEGINSET
RasterAnn.AnnDefine hObjectRuler, 100, 100, ANN_DEFINE_END
nRet = RasterAnn.AnnGetType(hObjectRuler)
If (nRet <> 0) Then Exit Sub
lObjectType = RasterAnn.AnnType
If (lObjectType <> ANN_OBJECT_RULER) Then
MsgBox "Error: AnnCalibrateRuler only works on ANNOBJECT_RULER objects"
Exit Sub
End If
nRet = RasterAnn.AnnCalibrateRuler(hObjectRuler, 10, ANN_UNIT_INCHES, 1#)
If (nRet <> 0) Then Exit Sub
MsgBox "Ruler has been calibrated to have a length of 10 inches. Now all existing and newly created ruler objects will be matched to this calibration."
dDpiX = RasterAnn.AnnGetBitmapDpiX(hObjectRuler)
dDpiY = RasterAnn.AnnGetBitmapDpiY (hObjectRuler)
'Match calibration to existing objects in container
nRet = RasterAnn.AnnSetBitmapDpiX(hObjectRuler, dDpiX, False)
nRet = RasterAnn.AnnSetBitmapDpiY(hObjectRuler, dDpiY, False)
'Set automation defaults so that all newly created objects have this calibration
nRet = RasterAnn.AnnSetBitmapDpiX(RasterAnn.AnnAutomation, dDpiX, False)
nRet = RasterAnn.AnnSetBitmapDpiY(RasterAnn.AnnAutomation, dDpiY, False)
End Sub