为什么在对话框里添加键盘响应函数(ONKEYDOWN)没有用??
解决方案 »
- 使用jrtplib时出错:Debug Assertion Failed
- vc对话框STYLE属性中的子集和重叠与非模式对话框中的区别
- 关于属性表+属性页(CPropertySheet+CPropertyPage)的问题向大家请教, 谢谢!
- OSD
- ASP.NET程序与VC程序怎么通过消息通信,高手帮忙!分不够可以再加..........
- 求购《COM技术内幕》一本(沈阳或本溪)。
- SQL server 复制表的语句是什么呀?
- 水仙花问题!高分求教!
- 怎样让只读的CEdit背景是白色的?
- 将插入的对话框首先显示
- 关于 System I/O的问题
- 请教高手:程序从debug版改为release版出现这样的问题,为什么?
{
if(pMsg->message==WM_KEYDOWN)
{
AfxMessageBox("你按了键盘!");
}
return CDialog::PreTranslateMessage(pMsg);}
怎样进行不同键的选择?
直接响应WM_KEYDOWN时,可以通过nChar来进行条件分支,如:
switch (nChar)
{
case (VK_LEFT):
函数1;
break;
.
.
}
你们那样重载怎样条件分支?
给点代码好吗?小弟很菜的!!
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message == WM_KEYDOWN)
switch(pMsg->wParam)
{
case VK_UP:
{
//do somethin
break;
}
case VK_DOWN:
{
break;
}
default:
break;
}
return CDialog::PreTranslateMessage(pMsg);
}
能具体给一下MSG* 中各参数的具体含义吗?
hwnd---
lParam---
message---
pt---
time---
wParam---
谢谢!!
Handle to the window whose window procedure receives the message.
message
Specifies the message identifier. Applications can only use the low word; the high word is reserved by the system.
wParam
Specifies additional information about the message. The exact meaning depends on the value of the message member.
lParam
Specifies additional information about the message. The exact meaning depends on the value of the message member.
time
Specifies the time at which the message was posted.
pt
Specifies the cursor position, in screen coordinates, when the message was posted.
所以应该重载他,去掉里面的内容,再次用这个setfocus
我只要50分,呵呵
部分代码
void CdlgDlg::OnSetFocus(CWnd* pOldWnd)
{
::SetFocus(this->m_hWnd);//焦点 // TODO: 在此处添加消息处理程序代码
}
void CdlgDlg::OnBnClickedButton1()
{
this->SetFocus();//设置焦点
}
void CdlgDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
MessageBox("fan",0,MB_OK);//效果
CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
}