|
|
以下是我用的方法,但是就是行不通?可以教教在下吗?
1)我先在我的GUI上画出一个Group Box,ID命名为IDC_STATIC_FRAME,并在Properties->Extended Styles上点上Client edge 和 Modal frame
2)#include <vfw.h>
#include <winuser.h>
#include <Windows.h>
3)link 上 vfw32.lib, user32.lib, winmm.lib
4)OnInitDialog上加上
CStatic* pst=(CStatic*)GetDlgItem(IDC_STATIC_FRAME);
pst->GetWindowRect(&m_rectFrame);
ScreenToClient(&m_rectFrame);
5)OnPaint上加上
m_bmp.GetBitmap(&bm);
dcMem.DeleteDC();
dcMem.CreateCompatibleDC(&dc);
dcMem.SelectObject(&m_bmp);
dc.StretchBlt(m_rectFrame.left, m_rectFrame.top,
m_rectFrame.Width(),m_rectFrame.Height(),
&dcMem,0,0,bm.bmWidth,bm.bmHeight, SRCCOPY);
6)我的Preview func
hWndC = capCreateCaptureWindow ( "Capture Window", WS_CHILD|WS_DLGFRAME,m_rectFrame.TopLeft().x, m_rectFrame.TopLeft().y,320, 240, GetSafeHwnd()/*hwndParent*/, 11011);
if(hWndC)
capDriverConnect (hWndC, 0);
else
{
AfxMessageBox("Error Cammera is not connected!");
exit(1);
}
SetTimer(1,66,NULL);
7)以下是我的OnTimer func
void CYourProject::OnTimer(UINT nIDEvent)
{
if(nIDEvent==1)// First Timer
{
capGrabFrame(hWndC); // simple macro that sample a single frame from the
// camera.
capEditCopy(hWndC); // simple macro that edit a copy of the frame.
OpenClipboard(); //like virtual memory.
//m_hBmp is a Handle to Bitmap.
m_hBmp = (HBITMAP)::GetClipboardData(CF_BITMAP);
CloseClipboard();
m_bmp.Detach(); //cleaning the bitmap.
m_bmp.Attach(m_hBmp); //connecting the bitmap throw the handle.
InvalidateRect(m_rectFrame,false); // m_rectFrame is the frame that the
// video stream will be present in.
OnPaint(); // calling to paint function to paint the bitmap
// into the frame on the dialog.
}
CDialog::OnTimer(nIDEvent);
}
我试了很多方法还是不行,有哪一位大大可以帮帮我吗?谢谢 |
|