Public Class Form1
    Private m_hCamera As IntPtr

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        m_hCamera = StCam.Open(0)
    End Sub

    Private Sub Form1_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
        If Not m_hCamera.Equals(IntPtr.Zero) Then
            StCam.Close(m_hCamera)
        End If
    End Sub

    Private Sub btnPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreview.Click
        StCam.CreatePreviewWindow( _
         m_hCamera, _
         "Preview", _
         StCam.WS_OVERLAPPEDWINDOW Or StCam.WS_VISIBLE, _
         0, 0, 0, 0, IntPtr.Zero, IntPtr.Zero, StCam.STCAM_FALSE)
        StCam.StartTransfer(m_hCamera)
    End Sub
End Class
