MFC View

// MFCView.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "resource.h"

class CMyView:public CView{
public:
	virtual void OnDraw(CDC *pDC);
	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnTest();
	afx_msg void OnPaint();

};
BEGIN_MESSAGE_MAP(CMyView,CView)
	ON_WM_PAINT()
	ON_COMMAND(ID_TEST,OnTest)
END_MESSAGE_MAP()
void CMyView::OnTest(){

	AfxMessageBox("OnTest");
}
void CMyView::OnPaint(){
	PAINTSTRUCT ps={0};
	HDC hDC=::BeginPaint(m_hWnd,&ps);
	TextOut(hDC,100,100,"View",4);
	::EndPaint(m_hWnd,&ps);
}
void CMyView::OnDraw(CDC *pDC){

}

class MCFViewFrame:public CFrameWnd{

	DECLARE_MESSAGE_MAP()
public:
	afx_msg int OnCreate(LPCREATESTRUCT lpCreate);
public:
	CMyView *m_wndView;
};
BEGIN_MESSAGE_MAP(MCFViewFrame,CFrameWnd)
	ON_WM_CREATE()
END_MESSAGE_MAP()

int MCFViewFrame::OnCreate(LPCREATESTRUCT lpCreate)
{
	CFrameWnd::OnCreate(lpCreate);
	m_wndView=new CMyView();
	//AFX_IDW_PANE_FIRST 默认的ID号 填充整个窗口
	m_wndView->Create(NULL,"View",
		WS_CHILD|WS_VISIBLE|WS_BORDER,CRect(100,100,200,200),this,
		AFX_IDW_PANE_FIRST);
	return 1;
}
class CViewApp:public CWinApp{
public:
	virtual BOOL InitInstance();

};
CViewApp theApp;
BOOL CViewApp::InitInstance(){
	MCFViewFrame *pWin=new MCFViewFrame();
	pWin->Create(NULL,"ViewApp",WS_OVERLAPPEDWINDOW,
		CFrameWnd::rectDefault,NULL,MAKEINTRESOURCE(IDR_MAINFRM));
	m_pMainWnd=pWin;
	m_pMainWnd->ShowWindow(SW_SHOW);
	m_pMainWnd->UpdateWindow();
return 1;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值