Chapter 4 — Sample Applications
55
FMSampleAppVB
Adding a Reference to the API
In Visual Basic there is no need to initialize the COM libraries explicitly. Simply
add a reference to the Filter Manager type library by selecting Project > Refer-
ences on the main menu and then check the box next to “Filter Manager 1.0 Type
Library.” This adds the necessary COM references to the Filter Manager API.
The clsFilterManagerClass
We have encapsulated the interface to the API in a class, clsFiltermanagerClass.
An object variable is declared with the following code:
' Declare a public object variable to respond to events.
Public WithEvents oArgusFilterManager As ArgusFM
The class initialization handles the creation of a new Filter Manager object, and
the class Cleanup function destroys the Filter Manager object. All other Filter
Manager interface tasks are performed through the class using the class variable
oArgusFilterManager.
Using the Filter Manager Object
After the class has been initialized the Public class variable oArgusFilterManager
can be used from the main form to perform all Filter Manager calls. The follow-
ing code, for example, starts an encode.
' OnStart()
' This method calls the Filter Manager interface method Start() to start
' an encode.
' In response, if VTR control is enabled, the VTR component rolls the
' tape deck, starting the other components when it determines that the
' mark-in is near.
Private Sub cmdOnStart_Click()
Dim lngResult As Long
lngResult = ClsFilterManager.oArgusFilterManager.Start
If lngResult < 0 Then
MsgBox “Error starting the encoder”
ClsFilterManager.SetEncoderState esError
Else
ClsFilterManager.SetEncoderState esStarted
End If
SetButtons
End Sub