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

📄 displaytextview.cpp

📁 VisualC高级编程技术精粹.rar
💻 CPP
字号:
// DisplayTextView.cpp : implementation of the CDisplayTextView class
//

#include "stdafx.h"
#include "DisplayText.h"

#include "DisplayTextDoc.h"
#include "DisplayTextView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDisplayTextView

IMPLEMENT_DYNCREATE(CDisplayTextView, CView)

BEGIN_MESSAGE_MAP(CDisplayTextView, CView)
	//{{AFX_MSG_MAP(CDisplayTextView)
	ON_WM_LBUTTONDOWN()
	ON_WM_CHAR()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)

	ON_MESSAGE(WM_MYCUSTOM_MSG,OnMyCustomMsg)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDisplayTextView construction/destruction

CDisplayTextView::CDisplayTextView()
{
	// TODO: add construction code here

}

CDisplayTextView::~CDisplayTextView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CDisplayTextView drawing

void CDisplayTextView::OnDraw(CDC* pDC)
{
	CDisplayTextDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CDisplayTextView printing

BOOL CDisplayTextView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CDisplayTextView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CDisplayTextView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CDisplayTextView diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CDisplayTextView message handlers

LRESULT CDisplayTextView::OnMyCustomMsg(WPARAM wParam, LPARAM lParam)
{
	CString csText = _T("");

	//格式化字符串
	csText.Format(_T("参数wParam和lParam分别是%d,%d"),wParam,lParam); 

	//输出字符串
	AfxMessageBox(csText); 

	return 0;
}

void CDisplayTextView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	CClientDC ClientDC(this);
	CString csOutText = _T("你点击了鼠标左键");

	//输出字符串
	ClientDC.TextOut(point.x,point.y,csOutText);

	//发送消息
	PostMessage(WM_MYCUSTOM_MSG,point.x,point.y);

	CView::OnLButtonDown(nFlags, point);
}

void CDisplayTextView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
	CClientDC ClientDC(this);
	CString csOutText = _T("你按下的字符键是:");
	csOutText += nChar;

	//输出字符串
	ClientDC.TextOut(300,300,csOutText);

	//发送消息
	SendMessage(WM_MYCUSTOM_MSG,nChar,nFlags);
	
	CView::OnChar(nChar, nRepCnt, nFlags);
}

⌨️ 快捷键说明

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