请帮忙看看,非常急。万分感谢!
第一次做视频采集系统,遇到了这样一个问题,程序如下:
bool m_bKeyPressed;
void CVidTestDlg::OnAcapture()
{
// TODO: Add your command handler code here
CString Filter;
CString Filename;
CRect Rect;
m_bKeyPressed=false;//赋初值为false
Filter = "Bitmap Files (*.bmp)|*.bmp|AVI Files (*.avi)|*.avi||";
CFileDialog FileDlg(FALSE, "BMP", NULL,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
Filter,
this);
if (FileDlg.DoModal() == IDOK)
{
RedrawWindow();
Filename = FileDlg.GetPathName();
while(!m_bKeyPressed)//此循环为连续捕捉图象
{
Capture(m_VFWImageProc, Filename);
}
m_VideoDisplay.GetWindowRect(Rect);
ScreenToClient(Rect);
m_VFWImageProc.EnablePreviewVideo(*this, Rect.TopLeft().x,Rect.TopLeft().y);
}
}
BOOL CVidTestDlg::PreTranslateMessage(MSG* pMsg)//消息传递函数
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_KEYDOWN)//键盘被按下
{
if(pMsg->wParam==VK_F12)//F12键被按下
m_bKeyPressed=true;
}
return CDialog::PreTranslateMessage(pMsg);
}
我想利用void CVidTestDlg::OnAcapture()函数连续捕捉图象,直到我按下F12键,此时消息传递函数BOOL CVidTestDlg::PreTranslateMessage(MSG* pMsg)将m_bKeyPressed的值赋为true。则此时图象捕捉完成。
问题是此消息捕捉函数对键盘输入好象不起作用,根本不响应任何键,请问这是为什么?请大家帮忙改改程序,在此感谢。