PrintAnnotations Example VB

This example uses the ShowPrintDialog method to enable the user to specify printing parameters. The image displayed in the Image Edit control is then printed.

Private Sub cmdPrint_Click() 
    On Error GoTo PrintErr
    'Display an image
    ImgEdit1.Image = "D:\image2\4page.tif"
    ImgEdit1.Display 
    'Reset NumCopies in case user printed multiple copies last time.
    ImgAdmin1.PrintNumCopies = 1 
    'If CancelError is true, an error is generated if user presses
    'cancel.  Trap the error to avoid trying to print the file.
    ImgAdmin1.CancelError = True 
    'Set filename to be printed to the displayed file. If this 
    'property is not set the dialog box will not display.
    ImgAdmin1.Image = ImgEdit1.Image
    ImgAdmin1.ShowPrintDialog Form1.hWnd 
    'Print the image using the parameters obtained from the print
    'dialog box (for example, start page, end page, and so on).
    ImgEdit1.PrintImage ImgAdmin1.PrintStartPage,
        ImgAdmin1.PrintEndPage, ImgAdmin1.PrintOutputFormat, 
        ImgAdmin1.PrintAnnotations 
PrintErr: 
    'User pressed the cancel button
        Exit Sub 
End Sub