在很多时候,我们都需要屏蔽键盘的Esc键,以此来减少用户的误操作。在Class View 列表右键需要屏蔽的类的类名,选择properties,安然选择Overrides里的PreTranslateMessage,添加此函数,接着对其进行处理。
BOOL CLoginDialog::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (WM_KEYDOWN == pMsg->message)
{
int iKey = (int)pMsg->wParam;
// 屏蔽键盘esc
if ((VK_ESCAPE == iKey) || (VK_RETURN == iKey))
{
return TRUE;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
本文介绍如何在ClassView列表中屏蔽特定类的Esc键和Enter键操作,减少用户误操作的可能性,通过在类的属性中设置PreTranslateMessage函数来实现功能。

4374

被折叠的 条评论
为什么被折叠?



