// set the icon for this dialog. the framework does this automatically
// when the application's main window is not a dialog
seticon(m_hicon, true); // set big icon
seticon(m_hicon, false); // set small icon
// todo: add extra initialization here
//下面就是要加的代码:
hwndc=capcreatecapturewindow ( "my own capture window",
ws_child | ws_visible , 2, 26, 602, 426, getdlgitem(idc_static)->getsafehwnd(), 0);
capdriverconnect(hwndc,0);
cappreview(hwndc, true);
//以上是要加的代码
return true; // return true unless you set the focus to a control
}
7,别急,最后一步,在对话框的“onpaint"函数中加入一条,如下:
void cmy2dlg:npaint()
{
if (isiconic())
{
cpaintdc dc(this); // device context for painting
// center icon in client rectangle
int cxicon = getsystemmetrics(sm_cxicon);
int cyicon = getsystemmetrics(sm_cyicon);
crect rect;
getclientrect(&rect);
int x = (rect.width() - cxicon + 1) / 2;
int y = (rect.height() - cyicon + 1) / 2;
// draw the icon
dc.drawicon(x, y, m_hicon);
}
else
{
cdialog:npaint();
}
capcapturesequencenofile(hwndc);//在这里,就这一句,这是不录到文件的情况,只是在界面上看看自己的尊容而已。
//如果要录到文件中就要用这条:capcapturesequence(hwndc);默认录到c盘根目录下,你找一找,一个很大的avi文件,就是它!
}
ok!完成!把摄相头插上,启动程序,你的超级大帅脸就呈现在屏幕上了!