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

📄 polygonattrdlg.cpp

📁 这是书上的代码
💻 CPP
字号:
// PolygonAttrDlg.cpp : implementation file
//

#include "stdafx.h"
#include "const.h"
#include "painted.h"
#include "paintobj.h"
#include "paintdoc.h"
#include "FillColorStatic.h"
#include "PolygonAttrDlg.h"
#include "PaintPolygon.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPolygonAttrDlg dialog


CPolygonAttrDlg::CPolygonAttrDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPolygonAttrDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPolygonAttrDlg)
	m_bFill = FALSE;
	m_nCount = 0;
	m_nId = 0;
	m_dx = 0.0;
	m_dy = 0.0;
	//}}AFX_DATA_INIT
	m_bChange=FALSE;
}


void CPolygonAttrDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPolygonAttrDlg)
	DDX_Control(pDX, IDC_FILLCOLOR, m_ctlFillColor);
	DDX_Control(pDX, IDC_SPIN1, m_ctlSpin);
	DDX_Check(pDX, IDC_BFILL, m_bFill);
	DDX_Text(pDX, IDC_COUNT, m_nCount);
	DDX_Text(pDX, IDC_ID, m_nId);
	DDX_Text(pDX, IDC_X, m_dx);
	DDX_Text(pDX, IDC_Y, m_dy);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPolygonAttrDlg, CDialog)
	//{{AFX_MSG_MAP(CPolygonAttrDlg)
	ON_BN_CLICKED(IDC_CHANGECOLOR, OnChangecolor)
	ON_EN_CHANGE(IDC_ID, OnChangeId)
	ON_EN_CHANGE(IDC_X, OnChangeX)
	ON_EN_CHANGE(IDC_Y, OnChangeY)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPolygonAttrDlg message handlers

void CPolygonAttrDlg::OnChangecolor() 
{
	// TODO: Add your control notification handler code here
	CColorDialog ColorDialog;
	// Invoke the common color selector
	// dialog box.
	if( ColorDialog.DoModal() == IDOK )
	{
		// We've set either the fill color or the
		// border color.		
		m_ctlFillColor.m_FillColor = ColorDialog.GetColor();		
	}	
	m_ctlFillColor.RedrawWindow();
}

BOOL CPolygonAttrDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CWnd* pWnd = GetDlgItem(IDC_ID);
	m_ctlSpin.SetBuddy(pWnd);
	m_ctlSpin.SetRange(0,m_nCount-1);	
	m_ctlSpin.SetPos(0);	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CPolygonAttrDlg::OnChangeId() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);	
	m_dx=((CPaintPolygon*) m_pActive1)->m_pntData[m_nId].x;
	m_dy=((CPaintPolygon*) m_pActive1)->m_pntData[m_nId].y;
	UpdateData(FALSE);
}

void CPolygonAttrDlg::OnChangeX() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if(((CPaintPolygon*) m_pActive1)->m_pntData[m_nId].x!=m_dx)
	{
		m_bChange=TRUE;
		((CPaintPolygon*) m_pActive1)->m_pntData[m_nId].x=m_dx;
	}	
}

void CPolygonAttrDlg::OnChangeY() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if(((CPaintPolygon*) m_pActive1)->m_pntData[m_nId].y!=m_dy)
	{
		m_bChange=TRUE;
		((CPaintPolygon*) m_pActive1)->m_pntData[m_nId].y=m_dy;
	}
	
}

⌨️ 快捷键说明

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