// 1. Head file declaration
// The header is included in the header, and guarantees VFW32.lib in the program directory.
#include
#pragma comment (Lib, "VFW32.LIB")
// Video device (camera) acquisition and initialization code snippet
// 2. Define class member variables
// defined variables defined in class members
HWND HcAptureWindow;
CButton M_Capturergn; // GrouPbox corresponds to how to CButton, very strange
// 3. Video Equipment (Camera) Get and Initialize Code
Rect CWRECT; CAPDRIVERCAPS CPS;
// m_capturergn is a pre-defined display video of the control (GroupBox) M_Capturergn.getClientRect (& CWRECT);
CWRECT.Right = CWRECT.LEFT 6400; CWRECT.BOTTOM = CWRECT.TOP 480;
if (hCaptureWindow) {capPreview (hCaptureWindow, FALSE); capDriverDisconnect (hCaptureWindow);} hCaptureWindow = capCreateCaptureWindow ( "video window", WS_CHILD | WS_VISIBLE, cwRect.left, cwRect.top, cwRect.right, cwRect.bottom, hCaptureRgn, ( int) 1); ASSERT (hCaptureWindow);! { "! connect the video input device error" MessageBox (); return;} if (capDriverConnect (hCaptureWindow, 0)) capDriverGetCaps (hCaptureWindow, & cps, sizeof (CAPDRIVERCAPS)); if ( ! cps.fcaptureinitialized) {MessageBox ("Video Enterprise initialization error!"); Return;}
if (cps.fHasDlgVideoSource) capDlgVideoSource (hCaptureWindow); if (cps.fHasDlgVideoFormat) capDlgVideoFormat (hCaptureWindow); if (cps.fHasDlgVideoDisplay) capDlgVideoDisplay (hCaptureWindow); capPreviewRate (hCaptureWindow, 20); capPreview (hCaptureWindow, TRUE); Invalidate () ;
// 4. Description: This article is used for reference when I write the code later, there are many problems.
// Please ask your master to pay for your personal attack!