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

📄 009view.cpp

📁 在C++环境中实现数的生成实现
💻 CPP
字号:
// 009View.cpp : implementation of the CMy009View class
//

#include "stdafx.h"
#include "009.h"

#include "009Doc.h"
#include "009View.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMy009View

IMPLEMENT_DYNCREATE(CMy009View, CView)

BEGIN_MESSAGE_MAP(CMy009View, CView)
	//{{AFX_MSG_MAP(CMy009View)
	ON_WM_LBUTTONDOWN()
	ON_WM_MOUSEMOVE()
	ON_WM_LBUTTONUP()
	//}}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)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMy009View construction/destruction

CMy009View::CMy009View()
{
	// TODO: add construction code here
	m_bLButtonDown = FALSE;
	m_hCross = AfxGetApp()->LoadStandardCursor(IDC_CROSS);

}

CMy009View::~CMy009View()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMy009View drawing

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

/////////////////////////////////////////////////////////////////////////////
// CMy009View printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CMy009View diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CMy009View message handlers

///--左键按下响应-------
void CMy009View::OnLButtonDown(UINT nFlags, CPoint point) 
{
	m_bLButtonDown = TRUE;
	m_ptStart = point;
	m_ptOld   = point;
	SetCapture();     //把以后的鼠标输入消息都送到本窗口
	
	CRect rect;
	GetClientRect(&rect);  //得到当前客户区的大小和位置,并保存在rect结构体中
	ClientToScreen(&rect); //把其参数点或矩形坐标从当前窗口转换到屏幕坐标
	ClipCursor(&rect);     //限定鼠标范围,鼠标不能到这个限定区域之外

	CView::OnLButtonDown(nFlags, point);
}


//----鼠标移到消息------------------------------
void CMy009View::OnMouseMove(UINT nFlags, CPoint point) 
{
	SetCursor(m_hCross);
	if(m_bLButtonDown)
	{
		CClientDC dc(this);  //用于在客户区画图和显示文本
		dc.SetROP2(R2_NOT);  //用来设置当前绘图方式

		dc.MoveTo(m_ptStart);
		dc.LineTo(m_ptOld);

		dc.MoveTo(m_ptStart);
		dc.LineTo(point);

		m_ptOld = point;
	}

	
	CView::OnMouseMove(nFlags, point);
}

//-----左键抬起响应---------------
void CMy009View::OnLButtonUp(UINT nFlags, CPoint point) 
{
	if(m_bLButtonDown)
	{
		m_bLButtonDown = FALSE;
		ReleaseCapture();
		ClipCursor(NULL);

		CClientDC dc(this);
		dc.SetROP2(R2_NOT);
		dc.MoveTo(m_ptStart);
		dc.LineTo(m_ptOld);

		dc.SetROP2(R2_COPYPEN);
		dc.MoveTo(m_ptStart);
		dc.LineTo(point);
	}

	
	CView::OnLButtonUp(nFlags, point);
}

⌨️ 快捷键说明

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