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

📄 devicepolygonattrdlg.cpp

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

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


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

/////////////////////////////////////////////////////////////////////////////
// CDevicePolygonAttrDlg dialog


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


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


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

/////////////////////////////////////////////////////////////////////////////
// CDevicePolygonAttrDlg message handlers

void CDevicePolygonAttrDlg::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();
}

void CDevicePolygonAttrDlg::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;
	}
}

void CDevicePolygonAttrDlg::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 CDevicePolygonAttrDlg::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);
}

BOOL CDevicePolygonAttrDlg::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
}

⌨️ 快捷键说明

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