本文实例讲述了C++处理键盘输入的方法,可实现简单处理键盘输入,分享给大家供大家参考。具体实现方法如下:
需要响应WM_CHAR消息:
#include <string> static std::string str;
str = str + char(wParam); ::InvalidateRect(hWnd, NULL, 0); return 0;
case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: 在此添加任意绘图代码... ::TextOut(hdc, 0, 0, str.c_str(),str.length()); EndPaint(hWnd, &ps); break;
希望本文所述对大家的C++程序设计有所帮助。