还是从打招呼开始吧,以免把她吓着了。于是,我战战兢兢的跟MFC say hello了。
| MyApp.h: class CMyApp : public CWinApp { public: virtual BOOL InitInstance(); }; // frame window class class CMyFrame : public CFrameWnd { public: CMyFrame(); protected: // "afx_msg" indicates that the function is part // of the MFC library message dispatch system afx_msg void OnPaint(); DECLARE_MESSAGE_MAP() }; MyApp.cpp: #include <afxwin.h> // MFC library header file declares base classes #include "myapp.h" BOOL CMyApp::InitInstance() { m_pMainWnd = new CMyFrame(); m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->UpdateWindow(); return TRUE; } BEGIN_MESSAGE_MAP(CMyFrame, CFrameWnd) ON_WM_PAINT() END_MESSAGE_MAP() CMyFrame::CMyFrame() { Create(NULL, "MYAPP Application"); } void CMyFrame::OnPaint() { CPaintDC dc(this); dc.TextOut(0, 0, "Hello, MFC!"); } |