PreTranslateMessage,就看看英文单词就可以理解是干什么的了,Pre(Previous 之前的),Translate(转换),message(消息)---什么 什么的 之前转换消息。就是在把消息发送给windows应用程序之前转换成你想处理的,比如说屏蔽所有的按键消息(WM_CHAR),这些键盘的ASCII码都要经过DispatchMessage派送给系统的应用程序。以下是评比键盘消息的一个简单的应用,代码如下:
BOOL 类名::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
CString m_OfferPrice;
GetWindowText(m_OfferPrice);
if (pMsg->message==WM_CHAR)
{
if ((pMsg->wParam<7)||(pMsg->wParam>57)||(pMsg->wParam>8&&pMsg->wParam<45/*&&pMsg->wParam!=43*/)||( pMsg->wParam==45)||(pMsg->wParam==47)) //屏蔽所有的字符键
return TRUE;
}
return CEdit::PreTranslateMessage(pMsg);
}