我自己继承CDialog class CMainForm : public CDialog
...
H文件:
virtual void OnKeyUp(UINT nchar,UINT nRepCnt,UINT nFlags);CPP文件:
void CMainForm::OnKeyUp(UINT nchar,UINT nRepCnt,UINT nFlags)
{
MessageBox(L"ff",0,0);
}
然后CMainForm* pMainForm = new CMainForm();
pMainForm->Create(IDD_MAINFORM, theApp.m_pMainWnd);
pMainForm->ShowWindow(SW_SHOW);
随便按键盘 问什么不能弹出提示框呢?有什么需要注意的地方呢?
...
H文件:
virtual void OnKeyUp(UINT nchar,UINT nRepCnt,UINT nFlags);CPP文件:
void CMainForm::OnKeyUp(UINT nchar,UINT nRepCnt,UINT nFlags)
{
MessageBox(L"ff",0,0);
}
然后CMainForm* pMainForm = new CMainForm();
pMainForm->Create(IDD_MAINFORM, theApp.m_pMainWnd);
pMainForm->ShowWindow(SW_SHOW);
随便按键盘 问什么不能弹出提示框呢?有什么需要注意的地方呢?
在PreTranslateMessage中过滤此消息。
{
// TODO: Add your specialized code here and/or call the base class
if( pMsg->message>=WM_KEYDOWN && pMsg->message<=WM_KEYUP)
{
this->SendMessage(pMsg->message,pMsg->wParam,pMsg->lParam);
return TRUE;
}
else
return CDialog::PreTranslateMessage(pMsg);
}
加这个就可以了``
{
//加这句试试
CDialog::OnKeyUp(UINT nchar,UINT nRepCnt,UINT nFlags);
MessageBox(L"ff",0,0);
}
在PreTranslateMessage中过滤此消息,如下 :
BOOL CMainForm::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if( pMsg->message>=WM_KEYDOWN && pMsg->message<=WM_KEYUP)
{
this->SendMessage(pMsg->message,pMsg->wParam,pMsg->lParam);
return TRUE;
}
else
return CDialog::PreTranslateMessage(pMsg);
}
===============================
如楼上所说,重写PreTranslateMessage即可
BOOL CMainForm::PreTranslateMessage(MSG* pMsg)
{
MessageBox(L"ff",0,0);
return CDialog::PreTranslateMessage(pMsg);
}我的对话框 是这样出来的pMainForm->ShowWindow(SW_SHOW); 不是Domodal为什么没有消息循环
如果lz
BOOL CMainForm::PreTranslateMessage(MSG* pMsg)
{
MessageBox(L"ff",0,0);
return CDialog::PreTranslateMessage(pMsg);
}
没有反应那么请你重载
CXXApp的的PreTranslateMessage虚函数
BOOL CXXApp::PreTranslateMessage(MSG* pMsg)
{
if ( ( 你的对话框->PreTranslateMessage( pMsg ) )
{
return true;
};
return CWinApp::PreTranslateMessage( pMsg );};
创建对话框的代码是在哪里出现的.是main()??
能说下,你这个程序主要几个步骤吗?如果是VC自动生成的话,点类视图就可以看APP类了,然后右键添加 虚Virtual Virtual函数,
选择里面的PreTranslateMessage就可以了.
程序没什么保密性吧. 我想看看代码..
QQ 32242132 ..
邮箱[email protected]