Smooth example for Visual Basic

Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Public hRgnAll As Long
Private Const RGN_OR = 2

'Declare the RasterProcess object WithEvents
Public WithEvents RasterProc As LEADRasterProcess

'Create the RasterProcess object and UnlockSupport
Private Sub Form_Load()
'.....
    Set RasterProc = CreateObject("LEADRasterProcess.LEADRasterProcess. ")
    LEADRasterView1.Raster.UnlockSupport L_SUPPORT_DOCUMENT, "TestKey"
'.....
End Sub
'This example smooths all nicks and bumps up to 2 pixels in length
'Long bumps/nicks are treated before short bumps/nicks
'A LEAD region is updated to show all the changes
'The Smooth Event is used to display information about bump or nick

Dim nRet As Integer
RasterProc.EnableDocCleanEvents = True
RasterProc.DocCleanSuccess = SUCCESS_REMOVE
nRet = RasterProc.Smooth(LEADRasterView1.Raster, 2, SMOOTH_SINGLE_REGION Or SMOOTH_LEAD_REGION Or SMOOTH_FAVOR_LONG)
If (nRet = 0) Then
    LEADRasterView1.RgnFrameType = RGNFRAME_COLOR
End If

Private Sub RasterProc_Smooth(ByVal nBumpOrNick As Long, ByVal fStartRow As Single, ByVal fStartCol As Single, ByVal fLength As Single, ByVal uHorV As Long)
Dim szType As String
Dim szHorV As String
If (nBumpOrNick = SMOOTH_BUMP) Then
    szType = "Bump"
Else
    szType = "Nick"
End If
If (uHorV = SMOOTH_HORIZONTAL_ELEMENT) Then
    szHorV = "Horz."
Else
    szHorV = "Vert."
End If
Debug.Print "Found " & szType & " at " & CStr(fStartRow) & "," & CStr(fStartCol) & " Length=" & CStr(fLength) & " - " & szHorV
End Sub