// An MFC program that processes WM_CHAR messages. #include #include #include "message1.h" char str[80]; // holds output string CMainWin::CMainWin() { Create(NULL, "Processing WM_CHAR Messages"); } // Initialize the application. BOOL CApp::InitInstance() { m_pMainWnd = new CMainWin; m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->UpdateWindow(); return TRUE; } // This is the application's message map. BEGIN_MESSAGE_MAP(CMainWin, CFrameWnd) ON_WM_CHAR() END_MESSAGE_MAP() // Process a WM_CHAR message. afx_msg void CMainWin::OnChar(UINT ch, UINT count, UINT flags) { CClientDC dc(this); dc.TextOut(1, 1, " ", 3); // erase previous char wsprintf(str, "%c", ch); dc.TextOut(1, 1, str, strlen(str)); } CApp App; // instantiate the application