Opening and Handling Devices: Save and restore device properties

The following programming example shows how you can use IC Imaging Control to save and restore device properties.
Language:Visual Basic 6
Version:3.0.3
Released on:April 7, 2005
Author:IC Imaging Control Support Department
Requirements:IC Imaging Control >2.1
Camera, converter or grabber with WDM Stream Class drivers.

The following programming example (Visual Basic 6) shows how you can use IC Imaging Control to save and restore device settings (see dialog on the right). Let us begin with two dialogs that are not shown here for simplicity reasons. With the button "Device...", the user accesses the built-in dialog to select a device, while the button "Properties..." leads to the adjustment of its settings. When the user clicks "Save Settings...", the program checks the device's validity (.DeviceValid). Then CommonDialog1.ShowSave activates the Windows dialog to save a file. Using only one function .SaveDeviceStateToFile IC Imaging Control writes the current parameters to the selected file:

Private Sub btnSaveSettings_Click()

    If ICImagingControl1.DeviceValid Then

        CommonDialog1.ShowSave

        If CommonDialog1.FileName <> "" Then
            ICImagingControl1.SaveDeviceStateToFile CommonDialog1.FileName
        End If

    End If

End Sub

When the user clicks "Restore Settings...", the program stops the image data stream (.LiveStop). Then CommonDialog1.ShowOpen activates the Windows dialog to open a file. Using only one function .LoadDeviceStateFromFile IC Imaging Control reads the current parameters out of the selected file. As a last step .LiveStart restarts the image data stream based on the new parameters.

Private Sub btnRestoreSettings_Click()

    If ICImagingControl1.LiveVideoRunning Then
        ICImagingControl1.LiveStop
    End If

    CommonDialog1.ShowOpen

    If CommonDialog1.FileName <> "" Then
        ICImagingControl1.LoadDeviceStateFromFile CommonDialog1.FileName, True
    End If

    If ICImagingControl1.DeviceValid Then
        ICImagingControl1.LiveStart
    End If
End Sub

The dialog window of the sample application.

Related Source Code Samples

Disclaimer
The source code that appears in the IC Imaging Control Source Code Library is indented for educational purposes only. The Imaging Source Europe GmbH, the manufacturer of IC Imaging Control, does not assume any kind of warranty expressed or implied, resulting from the use of the content of this page.

This site is part of The Imaging Source Network. Other sites include Company Portal, Image Processing, Astronomy Cameras, Astronomy Cameras Blog, Blog caméras d'astronomie, Astronomy Cameras Competition, TX Text Control, LiveDocx, phpLiveDocx and Forums.