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

📄 statuspage.cpp

📁 根据《VC++6.0 用户界面制作技术与应用实例》写的一些代码
💻 CPP
字号:
// StatusPage.cpp : implementation file
//

#include "stdafx.h"
#include "resource.h"
#include "StatusPage.h"
#include "math.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

IMPLEMENT_DYNCREATE(COrdinatePage, CPropertyPage)
IMPLEMENT_DYNCREATE(CSetPage, CPropertyPage)
IMPLEMENT_DYNCREATE(COSnapPage, CPropertyPage)


/////////////////////////////////////////////////////////////////////////////
// COrdinatePage property page

COrdinatePage::COrdinatePage() : CPropertyPage(COrdinatePage::IDD)
{
	//{{AFX_DATA_INIT(COrdinatePage)
	m_dStoW = 1.0;
	m_dWtoS = 1.0;
	m_dOriginX = 0.0;
	m_dOriginY = 0.0;
	m_dOriginZ = 0.0;
	//}}AFX_DATA_INIT
}

COrdinatePage::~COrdinatePage()
{
}

void COrdinatePage::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(COrdinatePage)
	DDX_Text(pDX, IDC_EDIT_STOW, m_dStoW);
	DDX_Text(pDX, IDC_EDIT_WTOS, m_dWtoS);
	DDX_Text(pDX, IDC_EDIT_X, m_dOriginX);
	DDX_Text(pDX, IDC_EDIT_Y, m_dOriginY);
	DDX_Text(pDX, IDC_EDIT_Z, m_dOriginZ);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(COrdinatePage, CPropertyPage)
	//{{AFX_MSG_MAP(COrdinatePage)
	ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_X, OnDeltaposSpinX)
	ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_Y, OnDeltaposSpinY)
	ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_Z, OnDeltaposSpinZ)
	ON_EN_KILLFOCUS(IDC_EDIT_WTOS, OnKillfocusEditWtos)
	ON_EN_KILLFOCUS(IDC_EDIT_STOW, OnKillfocusEditStow)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CSetPage property page

CSetPage::CSetPage() : CPropertyPage(CSetPage::IDD)
{
	//{{AFX_DATA_INIT(CSetPage)
	m_dGrid = 0.5;
	m_dSnap = 0.5;
	m_nGrid = 1;
	m_nOrtho = 1;
	m_nSnap = 1;
	//}}AFX_DATA_INIT
}

CSetPage::~CSetPage()
{
}

void CSetPage::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSetPage)
	DDX_Text(pDX, IDC_EDIT_GRID, m_dGrid);
	DDX_Text(pDX, IDC_EDIT_SNAP, m_dSnap);
	DDX_Radio(pDX, IDC_GRID_ON, m_nGrid);
	DDX_Radio(pDX, IDC_ORTHO_ON, m_nOrtho);
	DDX_Radio(pDX, IDC_SNAP_ON, m_nSnap);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSetPage, CPropertyPage)
	//{{AFX_MSG_MAP(CSetPage)
		// NOTE: the ClassWizard will add message map macros here
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// COSnapPage property page

COSnapPage::COSnapPage() : CPropertyPage(COSnapPage::IDD)
{
	m_nOSnapSize = 4 ;
	//{{AFX_DATA_INIT(COSnapPage)
	m_bCenter = FALSE;
	m_bEndPoint = FALSE;
	m_nMinPoint = FALSE;
	m_nQuardant = FALSE;
	//}}AFX_DATA_INIT
}

COSnapPage::~COSnapPage()
{
}

void COSnapPage::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(COSnapPage)
	DDX_Check(pDX, IDC_CENTER, m_bCenter);
	DDX_Check(pDX, IDC_ENDPOINT, m_bEndPoint);
	DDX_Check(pDX, IDC_MIDPOINT, m_nMinPoint);
	DDX_Check(pDX, IDC_QUARDANT, m_nQuardant);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(COSnapPage, CPropertyPage)
	//{{AFX_MSG_MAP(COSnapPage)
	ON_WM_HSCROLL()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()



void COrdinatePage::OnDeltaposSpinX(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
	// TODO: Add your control notification handler code here
	m_dOriginX += pNMUpDown->iDelta ;
	char tubf[80];
	sprintf(tubf , "%f",m_dOriginX) ;
	SetDlgItemText(IDC_EDIT_X,tubf);
	*pResult = 0;
}

void COrdinatePage::OnDeltaposSpinY(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
	// TODO: Add your control notification handler code here
	m_dOriginY += pNMUpDown->iDelta ;
	char tubf[80];
	sprintf(tubf , "%f",m_dOriginY) ;
	SetDlgItemText(IDC_EDIT_Y,tubf);
	*pResult = 0;
}

void COrdinatePage::OnDeltaposSpinZ(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
	// TODO: Add your control notification handler code here
	m_dOriginZ += pNMUpDown->iDelta ;
	char tubf[80];
	sprintf(tubf , "%f",m_dOriginZ) ;
	SetDlgItemText(IDC_EDIT_Z,tubf);
	*pResult = 0;
}

void COrdinatePage::OnKillfocusEditWtos() 
{
	// TODO: Add your control notification handler code here
	UpdateData();

	if(fabs(m_dWtoS)<1e-16)
	{
		AfxMessageBox("The scale of world to screen should not be zero!");
		GetDlgItem(IDC_EDIT_WTOS)->SetFocus();
	}
	else
	{
		m_dStoW = 1.0/m_dWtoS ;
		char tubf[80];
		sprintf(tubf , "%f",m_dStoW);
		SetDlgItemText(IDC_EDIT_STOW,tubf);
	}
}

void COrdinatePage::OnKillfocusEditStow() 
{
	// TODO: Add your control notification handler code here
	UpdateData();

	if(fabs(m_dStoW)<1e-16)
	{
		AfxMessageBox("The scale of world to screen should not be zero!");
		GetDlgItem(IDC_EDIT_STOW)->SetFocus();
	}
	else
	{
		m_dWtoS = 1.0/m_dStoW ;
		char tubf[80];
		sprintf(tubf , "%f",m_dWtoS);
		SetDlgItemText(IDC_EDIT_WTOS,tubf);
	}
}

BOOL COrdinatePage::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	// TODO: Add extra initialization here
	CSpinButtonCtrl* pSpin ;
	pSpin = (CSpinButtonCtrl*)GetDlgItem(IDC_SPIN_X);
	pSpin->SetRange(-10000,10000) ;

	pSpin = (CSpinButtonCtrl*)GetDlgItem(IDC_SPIN_Y);
	pSpin->SetRange(-10000,10000) ;

	pSpin = (CSpinButtonCtrl*)GetDlgItem(IDC_SPIN_Z);
	pSpin->SetRange(-10000,10000) ;
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

BOOL COSnapPage::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	// TODO: Add extra initialization here
	CSliderCtrl* pSlider = (CSliderCtrl*)GetDlgItem(IDC_OSNAPSIZE);
	pSlider->SetRange(2,20);
	pSlider->SetPos(m_nOSnapSize);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void COSnapPage::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	// TODO: Add your message handler code here and/or call default
	CSliderCtrl* pSlider = (CSliderCtrl*)GetDlgItem(IDC_OSNAPSIZE);
	m_nOSnapSize = pSlider->GetPos();

	CWnd* pWnd = GetDlgItem(IDC_PICTURE_OSNAP);
	CRect rect ;
	pWnd->GetClientRect(rect);
	int nCenterX = (rect.left+rect.right)/2;
    int nCenterY = (rect.top+rect.bottom)/2;

	CDC* pDC = pWnd->GetDC();
	pDC->Rectangle(rect);
	pDC->MoveTo(rect.left+5 ,nCenterY);
	pDC->LineTo(rect.right-5 ,nCenterY);
	pDC->MoveTo(nCenterX,rect.top+5);
	pDC->LineTo(nCenterX,rect.bottom-5);

	pDC->Rectangle(nCenterX-m_nOSnapSize,
		nCenterY-m_nOSnapSize,
		nCenterX+m_nOSnapSize,
		nCenterY+m_nOSnapSize);
	//CPropertyPage::OnHScroll(nSBCode, nPos, pScrollBar);
}

⌨️ 快捷键说明

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