Programming Examples
 
Annotations
Print
ActiveX Automation

This section offers tips on how to program the ActiveX controls that are included in Imaging, and the Imaging application using ActiveX Automation.

The main source of information on ActiveX syntax is the online Help file for the controls in the installation folder of Imaging for Windows. This file is named Imgocxd.hlp. Besides describing the syntax of the ActiveX controls and the COM object, imgocxd.hlp contains code examples for Visual Basic and C++. Additionally, the release media contains a Developer’s Guide, which articulates uses of the ActiveX controls and the Server Access Object. For information on programming ActiveX controls to access images on WMS Imaging Server (1.x) and in WMS Imaging and Workflow environments, please refer to Using Imaging Servers.

Annotations

How do I programmatically draw annotations?
After setting the appropriate annotation properties, use the ImgEdit Draw method to draw the annotation. For example, the following code will apply text from a file to an image.

ImgEdit1.SelectTool 9 'Text from file
ImgEdit1.AnnotationTextFile = "c:\text\disclaim.txt"
ImgEdit1.Draw 20, 20

Print

ImgAdmin.ShowPrintDialog shows the Print dialog, but never prints the image.
ImgAdmin.ShowPrintDialog is designed only to show the Print dialog and capture user modifications to it. In order to print the image, you need to then invoke ImgEdit.PrintImage. For example:

ImgAdmin1.Flags = 0
ImgAdmin1.ShowPrintDialog
frmMain.hWnd

If Err.Number = CANCEL_PRESSED
Then '32755 = Cancel button pressed
Exit Sub
EndIf

intFormat = ImgAdmin1.PrintOutputFormat
blnAnnotations = ImgAdmin1.PrintAnnotations
ImgEdit1.PrintImage
ImgAdmin1.PrintStartPage,
ImgAdmin1.PrintEndPage, intFormat, blnAnnotations

ActiveX Automation

How do I drive the Imaging application using ActiveX Automation?
The following code demonstrates how to create the Imaging application window as a stay-on-top object. It also shows how to create and perform actions on an image object displayed in the window, and how to close the image file and exit from the application.

'Declare the Application object and the ImageFile object

'as variables of type Object

Dim App As Object
Dim Img As Object

'Create the Application object (Standard VB call)

Set App = CreateObject("Imaging.Application")

'Create the ImageFile object
Set Img = App.CreateImageViewerObject(1)

'Set the application's TopWindow property to TRUE

'(stay on top)
App.TopWindow = True

'Call the ImageFile object Open Method to display page 1
'of myimage.tif
Img.Open "c:\images\myimage.tif", True, 1

'Create and rotate one Page object
Img.Pages(1).RotateLeft

'Return the height of the image from the Page object
x = Img.Pages(1).Height

'Create a PageRange object and print pages 1 and 2
y = Img.Pages(1,2).Print

'Display page 2 of the image
Img.ActivePage = 2

'Close ImageFile object
Img.Close

'Quit the application
App.Quit

 
Copyright 2000 - 2006 Global 360, Inc.