|
#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(0,TRUE); } class CMyApp:public CWinApp { public: BOOL InitInstance(); }; BOOL CMyApp::InitInstance(){ CMyWnd *pMainWnd=new CMyWnd; pMainWnd->Create(0,"MFC"); pMainWnd->ShowWindow(m_nCmdShow); pMainWnd->UpdateWindow(); m_pMainWnd=pMainWnd; return true; } CMyApp MyApp; |
|
|