钩子过程:
HWND g_hWnd=NULL;
LRESULT CALLBACK KeyboardProc(
int code, // hook code
WPARAM wParam, // virtual-key code
LPARAM lParam // keystroke-message information
)
{
if(!(lParam & 0xA0000000))
::SendMessage(g_hWnd,WM_CHAR,wParam,lParam);
return 0;
}
void CMyDlg::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
CString text;
text+=nChar;
MessageBox(text);
CDialog::OnChar(nChar, nRepCnt, nFlags);
}
接收的字母到都是大写,还有小键盘数字按下123 接收为:abc
求教???
HWND g_hWnd=NULL;
LRESULT CALLBACK KeyboardProc(
int code, // hook code
WPARAM wParam, // virtual-key code
LPARAM lParam // keystroke-message information
)
{
if(!(lParam & 0xA0000000))
::SendMessage(g_hWnd,WM_CHAR,wParam,lParam);
return 0;
}
void CMyDlg::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
CString text;
text+=nChar;
MessageBox(text);
CDialog::OnChar(nChar, nRepCnt, nFlags);
}
接收的字母到都是大写,还有小键盘数字按下123 接收为:abc
求教???
可以试试使用WM_KEYDOWN和WM_KEYUP消息,让TranslateMessage自己来解释
if(lParam & 0x80000000)
PostMessage(gHwnd, WM_KEYUP, wParam, lParam);
else
PostMessage(gHwnd, WM_KEYDOWN, wParam, lParam);