|
#include<afxwin.h> class CMyWnd:public CFrameWnd { private: char* ShowText; public: afx_msg void OnPaint(); afx_msg void OnLButtonDown(); DECLARE_MESSAGE_MAP() }; BEGIN_MESSAGE_MAP(CMyWnd,CFrameWnd) ON_WM_PAINT() ON_WM_LBUTTONDOWN() END_MESSAGE_MAP() void CMyWnd::OnPaint() { CPaintDC dc(this); dc.TextOut(20,20,ShowText); }
void CMyWnd::OnLButtonDown() { ShowText="有消息映射表的程序"; InvalidateRect(NULL,TRUE); }
class CMyApp:public CWinApp { public: BOOL InitInstance(); }; BOOL CMyApp::InitInstance() { CMyWnd* pMainWnd=new CMyWnd; pMainWnd->Create(0,"MFC_MSG_MAP_Example"); pMainWnd->ShowWindow(m_nCmdShow); pMainWnd->UpdateWindow(); m_pMainWnd=pMainWnd; return true; } CMyApp MyApp;
|