Sample Add-in
In the trivial case the sample code below provides an add-in which supports all
formats supported by the Visual Basic LoadPicture command.
Option Explicit
Public Function GetImage(Filename As String, ipic As Variant, _
params As
String)
Set ipic =
LoadPicture(Filename)
End Function
The code has to be implemented as a class module with the function name
"GetImage" fixed. It is added to CyPics using the add in manager where you
specify the image formats it supports and the [Project Name].[COM Module Name], for
example: ImageReader.Reader
COM Object Calling Sequence
CyPics configuration allows for the specification of the image file extensions to be
processed by an add-in, the COM object name (project.module) and an optional text
parameter string.
The filename will have been validated for being available and may be provided in
drive letter or UNC notation.
The image may be returned as a Visual Basic Picture object, a DIB or simply placed
on the clipboard.
The sample calling sequence is:
Dim objCom As Object
Dim objName As String
Dim filename As String
Dim iPic As Variant
Dim objParameters As String
Set objCom = CreateObject(objName)
On Error GoTo COMErrHandler
GetImageFromFile = objCom.GetImage(filename, iPic,
objParameters)
On Error GoTo StdErrHandler
' handle multiple format returns
If GetImageFromFile = 0 Then
' VB Picture
If TypeName(iPic) =
"Picture" Then
 myLead.SetPicture iPic
ElseIf TypeName(iPic) =
"Long" Then
 ' DIB Pointer
 myLead.SetDIB iPic
Else
 ' image on clipboard
 If myLead.Paste(PASTE_ISREADY) = 0 Then
  GetImageFromFile = 1024
 Else
  myLead.Paste 0
 End If
End If
End If
Set objCom = Nothing
We can provide a test program if required.
|