コード例 #1
0
        private void OpenCapture()
        {
            int    intWidth  = this.panelCamera.Width;
            int    intHeight = this.panelCamera.Height;
            int    intDevice = 0;
            string refDevice = intDevice.ToString();

            //创建视频窗口并得到句柄
            hHwnd = CameraForm.capCreateCaptureWindowA(ref refDevice, 1342177280, 0, 0, 640, 480, this.panelCamera.Handle.ToInt32(), 0);
            if (CameraForm.SendMessage(hHwnd, 0x40a, intDevice, 0) > 0)
            {                                                     //0x435,0x434,0x432是根据前面句柄而随即定义的参数
                CameraForm.SendMessage(this.hHwnd, 0x435, -1, 0); //该函数将指定的消息发送到一个或多个窗口
                CameraForm.SendMessage(this.hHwnd, 0x434, 0x42, 0);
                CameraForm.SendMessage(this.hHwnd, 0x432, -1, 0);
                CameraForm.SetWindowPos(this.hHwnd, 1, 0, 0, intWidth, intHeight, 6);
            }
            else
            {
                CameraForm.DestroyWindow(this.hHwnd);//销毁指定的窗口。
            }
        }
コード例 #2
0
 private void btnStop_Click(object sender, EventArgs e)
 {
     //停止视频注销视频句柄
     CameraForm.SendMessage(this.hHwnd, 0x40b, 0, 0);
     CameraForm.DestroyWindow(this.hHwnd);
 }