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

📄 ex9_2view.cpp

📁 只是一些书籍上的小代码!!!希望站长允许上传
💻 CPP
字号:
// Ex9_2View.cpp : implementation of the CEx9_2View class
//

#include "stdafx.h"
#include "Ex9_2.h"

#include "Ex9_2Doc.h"
#include "Ex9_2View.h"

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

/////////////////////////////////////////////////////////////////////////////
// CEx9_2View

IMPLEMENT_DYNCREATE(CEx9_2View, CView)

BEGIN_MESSAGE_MAP(CEx9_2View, CView)
	//{{AFX_MSG_MAP(CEx9_2View)
	ON_UPDATE_COMMAND_UI(AFX_IDC_COLOR_BLUE, OnUpdateIdcColorBlue)
	ON_UPDATE_COMMAND_UI(AFX_IDC_COLOR_GREEN, OnUpdateIdcColorGreen)
	ON_UPDATE_COMMAND_UI(AFX_IDC_COLOR_RED, OnUpdateIdcColorRed)
	ON_WM_LBUTTONDOWN()
	ON_COMMAND(AFX_IDC_COLOR_BLUE, OnIdcColorBlue)
	ON_COMMAND(AFX_IDC_COLOR_GREEN, OnIdcColorGreen)
	ON_COMMAND(AFX_IDC_COLOR_RED, OnIdcColorRed)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEx9_2View construction/destruction

CEx9_2View::CEx9_2View()
{    
	// TODO: add construction code here
    m_blue=0;
	m_green=0;
	m_red=0;
	m_flag=0;
}

CEx9_2View::~CEx9_2View()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CEx9_2View drawing

void CEx9_2View::OnDraw(CDC* pDC)
{
	CEx9_2Doc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	CPen RPen,GPen,BPen;
	if(m_red%2)
	{
		RPen.CreatePen(PS_SOLID,10,RGB(255,0,0));
		pDC->SelectObject(&RPen);
	}
	if(m_green%2)
	{
		GPen.CreatePen(PS_SOLID,10,RGB(0,255,0));
		pDC->SelectObject(&GPen);
	}
	if(m_blue%2)
	{
		BPen.CreatePen(PS_SOLID,10,RGB(0,0,255));
		pDC->SelectObject(&BPen);
	}
	if(m_flag)
		pDC->Ellipse(p.x-50,p.y-50,p.x+50,p.y+50);
}

/////////////////////////////////////////////////////////////////////////////
// CEx9_2View diagnostics

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CEx9_2View message handlers

void CEx9_2View::OnUpdateIdcColorBlue(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	if(m_blue%2)
	{
		pCmdUI->SetCheck(true);
		m_green=0;
		m_red=0;
	}
	else
		pCmdUI->SetCheck(false);
}

void CEx9_2View::OnUpdateIdcColorGreen(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	if(m_green%2)
	{
		pCmdUI->SetCheck(true);
		m_red=0;
		m_blue=0;
	}
	else
		pCmdUI->SetCheck(false);
}

void CEx9_2View::OnUpdateIdcColorRed(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	if(m_red%2)
	{
		pCmdUI->SetCheck(true);
		m_green=0;
		m_blue=0;
	}
    else
		pCmdUI->SetCheck(false);
}

void CEx9_2View::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	m_flag=1;
	p.x=point.x;
	p.y=point.y;
	this->Invalidate(true);
	CView::OnLButtonDown(nFlags, point);
}

void CEx9_2View::OnIdcColorBlue() 
{
	// TODO: Add your command handler code here
	m_blue++;
	
}

void CEx9_2View::OnIdcColorGreen() 
{
	// TODO: Add your command handler code here
	m_green++;
	
}

void CEx9_2View::OnIdcColorRed() 
{
	// TODO: Add your command handler code here
	m_red++;
	
}

⌨️ 快捷键说明

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