Basic Use of VCD Properties

This chapter illustrates the basic functionality of the VCDProperties. It shows you how to retrieve interfaces which allow you to manipulate elements, such as the value or the automation state of a property.

Introduction

This sample uses the "Brightness" property to demonstrate how the properties are organized and how they are accessed. First, the VCDPropertyItem for "Brightness" is retrieved from the VCDPropertyItems collection. Then a switch and a range interface is retrieved from the respective elements of this VCDPropertyItem. The switch interface is used to turn the automation state of this property on and off. The range interface is used to manipulate the value of this property.

The source code for this sample program can be found in the samples\VB6\VCD Simple sample source directory.

Creating the Project

Create a new project and add IC Imaging Control to the form. Before you run the program, select the video device, input and video format as shown in the First Steps in Visual Basic 6 chapter. Alternatively, run the program without selecting a device. In this case, the program shows the device selection dialog that ships with IC Imaging Control. If you close this dialog without selecting a device, the program displays an error message and terminates.

In order to specify a certain property, the module VCDPropertyID.bas must be added to the project. It can be found in the samples\VB6\common directory. The module contains the IDs that are needed to specify a property. To add the module to your project select Project from the menu and select Add Module. In the dialog, click the Existing tab and browse to the samples\VB6\common folder. Select the file VCDPropertyID.bas and click the Open button. The module is now part of your project.

Now add a check box and a slider (or 'trackbar') to the form. Name the check box chkBrightnessAuto and the slider sldBrightness.

Retrieving a VCDPropertyItem

After a valid video capture device has been selected, the VCDPropertyItem for "Brightness" is retrieved:

Just declare a variable of type VCDPropertyItem and use the VCDPropertyItems.FindItem method to assign the appropriate property. The property item that should be retrieved must be specified by its ID as mentioned above. In this case, it is VCDID_Brightness for the "Brightness" property item.

Retrieving Interfaces and Initialize the Controls

Properties consist of one or more elements like the value, automation state, one push operation and further parameters, if supported. To manipulate a property, interfaces are used. They can be retrieved from the elements of a property item. Declare 2 global variables that will hold the interfaces to the value and the automation state:

The following code shows you how to actually retrieve a switch and a range interface and how to get their current states in order to initialize the associated user controls.

The VCDPropertyElements.FindInterface method of the property item is used to retrieve an interface. As described above, a property item consists of one or more elements which provide one or more interfaces. Therefore, the element ID and the interface ID have to be specified when calling the VCDPropertyElements.FindInterface method.

Now that the we have the interfaces, the user controls can be initialized. The following code shows you how this is done:

As the code above shows, the interface classes let you easily access the elements of a property item.

Manipulating the elements of a Property

In this final step, we want to show you how to use the interfaces to manipulate a property. Add a Click event for the check box and a Scroll event for the slider. The check box toggles the automation state of the "Brightness" property. The code looks as follows:

The code above just assigns the current state of the check box to the automation element of the "Brightness" property. Additionally, the slider will be disabled, if the automation state is on.

The code for the Scroll event of the slider is even simpler:

Now you can run the program and manipulate the "Brightness" property, using the slider and the check box.

<< Programmer's Guide