您的位置:首页 > 移动开发

win32 Application 模板 建立 MFC程序

2010-02-05 09:29 429 查看
#include <Afxwin.h>
class CMyApp:public CWinApp
{
BOOL InitInstance();
};
class CMyWindow:public CFrameWnd
{
// public:
// CMyWindow();
// ~CMyWindow();
//afx_msg void OnPaint();
public:
void OnPaint();
afx_msg void OnNcPaint( );
DECLARE_MESSAGE_MAP();
};
#include "hello.h"
CMyApp theApp;
BEGIN_MESSAGE_MAP(CMyWindow,CFrameWnd)
ON_WM_PAINT()
ON_WM_NCPAINT()
END_MESSAGE_MAP()
CMyApp::InitInstance()
{
CMyWindow *MainWnd = new CMyWindow;
MainWnd->Create(NULL,"llsls");
m_pMainWnd = MainWnd;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
// ::MessageBox(0,"Hello","Simple MFC",MB_OK);
return true;
}
void CMyWindow::OnPaint()
{
CClientDC pDC(this);

CRect rc;
GetClientRect(&rc);
PAINTSTRUCT ps;
//BeginPaint(&ps);
//pDC.SetBkColor(TRANSPARENT);
//pDC.Rectangle(CRect(0, 0, 100, 100));

pDC.DrawText(_T("hello,world"),&rc,DT_SINGLELINE | DT_CENTER | DT_VCENTER );
// EndPaint(&ps);
// ReleaseDC(pDC);
CFrameWnd::OnPaint();

}
void CMyWindow::OnNcPaint()
{
// CDC *pDC = GetWindowDC();
// CRect rc;
// // GetClientRect(&rc);
// pDC->Rectangle(CRect(0, 0, 100, 100));
// ReleaseDC(pDC);
//dc.DrawText(_T("hello,world"),&rc,DT_SINGLELINE | DT_CENTER | DT_VCENTER );

}
// CMyWindow::CMyWindow()
// {
//
//
// }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: