1111111 (22.01.2013 14:45, просмотров: 230) ответил 1111111 на Гугли AVICAP32.DLL, запускается с полпинка
Вот в помощь куски говнокода "абы работало". Со считыванием картинки перебор - при перекрытии панельки окном считывается и окно, сам разбирайся откуда ее правильнее забирать Кинь на форму панельку Panel1, в ней будет идти отображение.
#include <windows.h>
#define VFWAPI WINAPI
const int WM_CAP_START = WM_USER;
const int WM_CAP_STOP = WM_CAP_START + 68;
const int WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10;
const int WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11;
const int WM_CAP_SAVEDIB = WM_CAP_START + 25;
const int WM_CAP_GRAB_FRAME = WM_CAP_START + 60;
const int WM_CAP_SEQUENCE = WM_CAP_START + 62;
const int WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20;
const int WM_CAP_SET_SCALE = 0x435;
const int WM_CAP_SET_PREVIEWRATE = 0x434;
const int WM_CAP_SET_PREVIEW = 0x432;
typedef HWND (VFWAPI *cCCW)(LPCWSTR,DWORD,int,int,int,int,HWND,int);
HMODULE hMod;
HWND hWndc;
Graphics::TBitmap *Bmp;
HDC DC;
TCanvas *Canvas = new TCanvas;
bool Open = false;
//***********************
//подключиться к камере
cCCW lpFunc;
hMod = LoadLibrary("AVICAP32.DLL");
if(!hMod)
{MessageBox(NULL,"Error - module",NULL,0);}
lpFunc = (cCCW)GetProcAddress(hMod,"capCreateCaptureWindowW");
if(!lpFunc)
{MessageBox(NULL,"Error - function",NULL,0);}
hWndc = lpFunc((LPCWSTR) "Windows App",
WS_CHILD | WS_VISIBLE, 0, 0, Panel1->Width, Panel1->Height, Panel1->Handle,(int)0);
if( hWndc != 0)
if (SendMessage(hWndc, WM_CAP_DRIVER_CONNECT, 0, 0) > 0)
{
SendMessage(hWndc, WM_CAP_SET_SCALE, -1, 0);
SendMessage(hWndc, WM_CAP_SET_PREVIEWRATE, 0x42, 0);
SendMessage(hWndc, WM_CAP_SET_PREVIEW, -1, 0);
SetWindowPos(hWndc, HWND_TOPMOST, 0, 0, Panel1->Width, Panel1->Height, 6);
Open = true;
}
Bmp = new Graphics::TBitmap;
Bmp->PixelFormat = pf24bit;
Bmp->Width = Panel1->Width;
Bmp->Height = Panel1->Height;
//***********************
//***********************
//отключиться
if( Open )
SendMessage(hWndc, WM_CAP_DRIVER_DISCONNECT, 0, 0);
if( hWndc )
DestroyWindow( hWndc );
hWndc = 0;
if(hMod)
FreeLibrary(hMod);
hMod = 0;
Open = false;
//***********************
//***********************
//цап картинку в Bmp
DC = GetDC(hWndc);
Canvas->Handle = DC;
Bmp->Canvas->CopyRect(Screen->DesktopRect, Canvas, Screen->DesktopRect);
//***********************