////////////////////////////////////////////////////////////////////////////// //文件: CScaleUnitPage.cpp //主要功能: // //程序编写: 2006-12-07 // // ///////////////////////////////////////////////////////////////////////////// #include "stdafx.h" //#include "DFDrawPro.h" #include "ScaleUnitPage.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CScaleUnitPage property page IMPLEMENT_DYNCREATE(CScaleUnitPage, CPropertyPage) CScaleUnitPage::CScaleUnitPage() : CPropertyPage(CScaleUnitPage::IDD) { //{{AFX_DATA_INIT(CScaleUnitPage) m_bXnotY = FALSE; m_xunitSel = 0; m_yunitSel = 0; msPerCM = 100.0; //}}AFX_DATA_INIT } CScaleUnitPage::~CScaleUnitPage() { } void CScaleUnitPage::DoDataExchange(CDataExchange* pDX) { CPropertyPage::DoDataExchange(pDX); //{{AFX_DATA_MAP(CScaleUnitPage) DDX_Check(pDX, IDC_CHECK_XY, m_bXnotY); DDX_CBIndex(pDX, IDC_COMBO_xunit, m_xunitSel); DDX_CBIndex(pDX, IDC_COMBO_yunit, m_yunitSel); DDX_Text(pDX, IDC_EDIT_cm_ms, msPerCM); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CScaleUnitPage, CPropertyPage) //{{AFX_MSG_MAP(CScaleUnitPage) ON_CBN_SELCHANGE(IDC_COMBO_yunit, OnSelchangeCOMBOyunit) ON_CBN_SELCHANGE(IDC_COMBO_xunit, OnSelchangeCOMBOxunit) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CScaleUnitPage message handlers void CScaleUnitPage::OnSelchangeCOMBOyunit() { UpdateData(); if(!m_bXnotY) m_xunitSel = m_yunitSel; switch(m_yunitSel) { case 5: case 6: Show(TRUE); break; default: Show(FALSE); break; } UpdateData(FALSE); } void CScaleUnitPage::OnSelchangeCOMBOxunit() { UpdateData(); if(!m_bXnotY) m_yunitSel = m_xunitSel; switch(m_yunitSel) { case 5: case 6: Show(TRUE); break; default: Show(FALSE); break; } UpdateData(FALSE); } double CScaleUnitPage::GetUnitX() { return GetUnit(m_xunitSel); } double CScaleUnitPage::GetUnitY() { return GetUnit(m_yunitSel); } /* 0 公里 kilometres 1 米 metre 2 分米 decimeter 3 厘米 centimeter 4 毫米 millimetres 5 秒 second 6 毫秒 millisecond 7 英尺 foot = 304.8mm 8 英寸 inch = 25.4mm 9 英里 mile = 1.609*1e6mm 10 码 yard = 914.4mm 11 海里 nautical mile = 1852000mm 12 俄里 Russian mile = 1.0668*1e6mm 13 俄丈 Russian unit of length = 2133.6mm 14 日里 Japanese mile = 3.9273*1e6mm 15 日尺 Japanese foot = 303mm; */ double CScaleUnitPage::GetUnit(int sel)//返回的单位为 毫米 { CUnit cu; cu.msPerCM = msPerCM; return cu.Millimetres((CUnit::EType)sel); } void CScaleUnitPage::Show(BOOL bFlag) { GetDlgItem(IDC_STATIC_cm)->ShowWindow(bFlag); GetDlgItem(IDC_STATIC_ms)->ShowWindow(bFlag); GetDlgItem(IDC_EDIT_cm_ms)->ShowWindow(bFlag); } BOOL CScaleUnitPage::OnInitDialog() { CPropertyPage::OnInitDialog(); m_psp.dwFlags &= ~PSH_HASHELP; if(m_xunitSel==5 || m_xunitSel==6 || m_yunitSel==5 || m_yunitSel==6) Show(TRUE); else Show(FALSE); if(m_xunitSel != m_yunitSel) m_bXnotY = TRUE; UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } BOOL CScaleUnitPage::OnSetActive() { CPropertySheet* pSheet = (CPropertySheet*)GetParent(); ASSERT_KINDOF(CPropertySheet, pSheet); pSheet->SetWizardButtons(PSWIZB_NEXT); return CPropertyPage::OnSetActive(); } LRESULT CScaleUnitPage::OnWizardNext() { // TODO: Add your specialized code here and/or call the base class return CPropertyPage::OnWizardNext(); }