先看下例子代码
#include <afxwin.h>
class CMyFrameWnd : public CFrameWnd
{
public:
CMyFrameWnd();
virtual ~CMyFrameWnd();
//
DECLARE_DYNCREATE(CMyFrameWnd)
DECLARE_MESSAGE_MAP()
protected:
afx_msg void OnPaint();
};
class CMyApp:public CWinApp
{
public:
virtual BOOL InitInstance();
};
BOOL CMyApp::InitInstance()
{
m_pMainWnd = new CMyFrameWnd;
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
CMyApp theApp;
//////////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNCREATE(CMyFrameWnd,CFrameWnd)
BEGIN_MESSAGE_MAP(CMyFrameWnd,CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()
CMyFrameWnd::CMyFrameWnd()
{
Create(NULL,"hello");
}
CMyFrameWnd::~CMyFrameWnd()
{
}
void CMyFrameWnd::OnPaint()
{
CPaintDC dc(this);
CRect rc;
GetClientRect(rc);
dc.DrawText("Hello",-1,&rc,DT_VCENTER | DT_CENTER | DT_SINGLELINE);
}
#include <afxwin.h>
class CMyFrameWnd