⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex4_1view.cpp

📁 C++程序设计源代码例
💻 CPP
字号:
// Ex4_1View.cpp : implementation of the CEx4_1View class
//

#include "stdafx.h"
#include "Ex4_1.h"

#include "Ex4_1Doc.h"
#include "Ex4_1View.h"

#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CEx4_1View

IMPLEMENT_DYNCREATE(CEx4_1View, CView)

BEGIN_MESSAGE_MAP(CEx4_1View, CView)
	//{{AFX_MSG_MAP(CEx4_1View)
	ON_COMMAND(ID_TOOLBAR_SAYHELLO, OnToolbarSayhello)
	ON_COMMAND(ID_TOOLBAR_CLEAR, OnToolbarClear)
	ON_WM_MOUSEMOVE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEx4_1View construction/destruction

CEx4_1View::CEx4_1View()
{
	// TODO: add construction code here
	m_OutString="";

}

CEx4_1View::~CEx4_1View()
{
}

BOOL CEx4_1View::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CEx4_1View drawing

void CEx4_1View::OnDraw(CDC* pDC)
{
	CEx4_1Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	pDC->TextOut (1,1,m_OutString);
}

/////////////////////////////////////////////////////////////////////////////
// CEx4_1View diagnostics

#ifdef _DEBUG
void CEx4_1View::AssertValid() const
{
	CView::AssertValid();
}

void CEx4_1View::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CEx4_1Doc* CEx4_1View::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx4_1Doc)));
	return (CEx4_1Doc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CEx4_1View message handlers

void CEx4_1View::OnToolbarSayhello() 
{
	// TODO: Add your command handler code here
	m_OutString="Welcome to VC learning!";  
	this->Invalidate(true); 
	
}

void CEx4_1View::OnToolbarClear() 
{
	// TODO: Add your command handler code here
	m_OutString=""; 
	this->Invalidate(true);
	
}


void CEx4_1View::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	CMainFrame *pMainFrame=(CMainFrame*)AfxGetMainWnd();	
	CStatusBar *pStatusBar=&pMainFrame->m_wndStatusBar;	
	if(pStatusBar)	
	{     
		CString str;	 
		str.Format("X:%d,y:%d",point.x,point.y);	 
		pStatusBar->SetPaneText(0,str);  	
	}
	
	CView::OnMouseMove(nFlags, point);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -