//In [Project Properties - Linker - Input - Additional Dependencies]
//add Vfw32.lib
#include "Vfw.h"
HWND hCapture;
//skipped...
VOID DriverDisconnect()
{
SendMessage(hCapture,
WM_CAP_DRIVER_DISCONNECT, NULL, NULL);
}
BOOL IsCaptureConnected()
{
CAPDRIVERCAPS psCaps ;
ZeroMemory(&psCaps, sizeof(psCaps));
SendMessage(hCapture, WM_CAP_DRIVER_GET_CAPS,
(WPARAM) sizeof(CAPDRIVERCAPS), (LPARAM) &psCaps);
return psCaps.fCaptureInitialized;
}
BOOL DriverConnect()
{
SendMessage(hCapture, WM_CAP_DRIVER_CONNECT, NULL, NULL);
return IsCaptureConnected();
}
VOID StartPreview()
{
SendMessage(hCapture, WM_CAP_SET_PREVIEWRATE, 15,0);
SendMessage(hCapture, WM_CAP_SET_PREVIEW, 1,0);
SendMessage(hCapture, WM_CAP_SET_OVERLAY, 1,0);
}
VOID ReleaseCaptureWindow()
{
if (hCapture != NULL)
{
DriverDisconnect();
DestroyWindow(hCapture);
hCapture=NULL;
}
}
VOID ResizeCaptureWindow()
{
BITMAPINFOHEADER bmpinfo;
ZeroMemory(&bmpinfo, sizeof(bmpinfo));
bmpinfo.biSize = sizeof(bmpinfo);
SendMessage(hCapture, WM_CAP_GET_VIDEOFORMAT,
(WPARAM) sizeof(bmpinfo), (LPARAM) &bmpinfo);
SetWindowPos(hCapture, 0,0,0, bmpinfo.biWidth,
bmpinfo.biHeight, SWP_SHOWWINDOW);
}
VOID InitCaptureWindow(HWND hWnd)
{
hCapture = capCreateCaptureWindow(NULL,
WS_CHILD|WS_VISIBLE, 0,0,1,1, hWnd, 1);
if (hCapture == NULL) return;
if (DriverConnect())
{
SendMessage(hCapture, WM_CAP_SET_SCALE, 1,0);
ResizeCaptureWindow();
StartPreview();
}
}
|
Apr.15, 2008: C++ version added
May 27, 2007: all capWindow functionality moved to Custom control
Oct.12, 2004: SaveToDib method captures and saves a single image as a device-independent bitmap (DIB).
Windows Image Acquisition Automation Layer
The Microsoft Windows Image Acquisition (WIA) Automation Layer 2.0 is a full-featured image manipulation component that provides end-to-end image processing capabilities. The WIA Automation Layer makes it easy to acquire images on digital cameras, scanners, or Web cameras, and to rotate, scale, and annotate your image files.
Applications that use the WIA Automation LayerAPI require Windows XPService Pack 1 (SP1) or later. Earlier versions of Windows are not supported. You will need WIAAut.dll to use the WIA Automation Layer.
* * *
You may have several capture windows created and fed from different Video Sources. You can not feed two capture windows from same source.
For example, now I have two digital cameras connected through USB -- Dimera 350C and Logitech QuickCam -- and one more video source, ATI TV Wonder Pro card that receives TV channels through coaxial cable.

With slightly modified code I can create three capture windows, one for each video source. All three windows simultaneously display preview from their sources.
* * *
Window styles WS_SYSMENU, WS_CAPTION and WS_THICKFRAME applied to the capture window make it movable and resizable. WS_CHILD must be present in any combination of window styles. |