Visual Basic sample code

 

'--------------------------------------------------------------------------

'DDE SAMPLE CODE. Development environment:Microsoft Visual Basic v2.0, v3.0

' File: VB_DDE.TXT

' App: Imagenation v3.50

' Rev: 1.0

'  Date: 3 December 1993

'--------------------------------------------------------------------------

'**************************************************************************

'Sample procedure to illustrate the launch of Imagenation, the connection

'to it and the execution of some basic DDE API commands

'**************************************************************************

 

'symbol constant declarations

Const IMAGE_PATH = "c:\image\" 'Imagenation path for execution

Const IMAGE_APP = "image.exe" 'Imagenation file name for execution

Const SH_NORMAL = 1 'application shell mode: normal w. focus

Const DDE_APP_PLUS_TOPIC = "Imagenation|Imaging" 'DDE Application

'& Topic pair

Const DDE_TIMEOUT = 300 'timeout is approx 30 seconds

Const LINKMODE_NONE = 0 'DDE conversation link mode values

Const LINKMODE_MANUAL = 2

'--------------------------------------------------------------------------

 

Sub cmdExecute_Click ()

'this function is provided as an example only and provides no error

'checking capabilities. It assumes:

' 1) Imagenation is not running

' 2) connection is successful on first attempt

' 3) this procedure is associated with a command button called

' "Execute"

' 4) the TextBox control referenced here: "txtDdeXactionBuffer"

' contains the path and file name of the layer or document to be

' viewed.

' 5) the file to be viewed is a file format supported by Imagenation

 

Dim Launch as Integer  'Boolean: -1=True, 0=False

Dim sDdeCmd as String  'variable for DDE cmd string

Dim ImDocwinID as String 'DocwinID for use in other DDE cmds

Dim ImNewLayerID as String 'LayerID for use in other DDE cmds

 

On Error Resume Next

 

'launch application

Launch = (Shell(IMAGE_PATH & IMAGE_APP, SH_NORMAL) > 32)

'if shell returns > 32, launch successful: Launch = -1

 

txtDdeXactionBuffer.LinkMode = LINKMODE_NONE

'mode=0, initialize to none to avoid err while topic & item are set

txtDdeXactionBuffer.LinkTopic = DDE_APP_PLUS_TOPIC

txtDdeXactionBuffer.LinkMode = LINKMODE_MANUAL

txtDdeXactionBuffer.LinkTimeout = DDE_TIMEOUT

'max wait for DDE application to respond

 

'execute a series of DDE cmds through link established between

'Imagenation and the txtDdeXactionBuffer TextBox form control.

 

'1 execute a DDE transaction: load image into Imagenation

sDdeCmd = "[OpenDocwin(0,0,""" & txtDdeXactionBuffer.Text & """,""" & txtDdeXactionBuffer.Text & """,0,0,0)]"

txtDdeXactionBuffer.LinkItem = sDdeCmd

txtDdeXactionBuffer.LinkRequest

 

'2 execute a DDE transaction: get DocwinID for image just viewed

sDdeCmd = "[GetDocwin]"

txtDdeXactionBuffer.LinkItem = sDdeCmd

txtDdeXactionBuffer.LinkRequest

ImDocwinID = txtDdeXactionBuffer.Text

'3 execute a DDE transaction: import prototype layer(Annotation)

'into window(DocwinID)

sDdeCmd = "[ImportLayer(" & ImDocwinID & ",""c:\PROTOLAY.EDT"",""Prototype Layer"",0)]"

txtDdeXactionBuffer.LinkItem = sDdeCmd

txtDdeXactionBuffer.LinkRequest

ImNewLayerID = txtDdeXactionBuffer.Text

End Sub

 

'---------------------------------------------------------------------

 

Back to Starting and ending a conversation with Imagenation