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

📄 page1.cpp

📁 Windows CE的注册表编辑器和数据库操作源码
💻 CPP
字号:
// Page1.cpp : implementation file
//

#include "stdafx.h"
#include "Currency_CE.h"
//#include "FloatEdit.h"
#include "Page1.h"

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

extern CStringArray m_SettingArray;
extern CStringArray m_SettingArray2;
double MyStrToD(CString s,int& dec);
CString MyDtoStr(double d,int& dec,int& sign);
void ReCalcOutputValue();
CFloatEdit* g_pEdit1;
CReadOnlyEdit* g_pEdit2;//CFloatEdit*
CComboBox* g_pComboC1;
CComboBox* g_pComboC2;
UINT m_CurrSel1;
UINT m_CurrSel2;
/////////////////////////////////////////////////////////////////////////////
// CPage1 property page

IMPLEMENT_DYNCREATE(CPage1, CPropertyPage)

CPage1::CPage1() : CPropertyPage(CPage1::IDD)
{
	//{{AFX_DATA_INIT(CPage1)
	//}}AFX_DATA_INIT
}

CPage1::~CPage1()
{
}

void CPage1::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPage1)
//	DDX_Control(pDX, IDC_EDIT2, m_f2);
//	DDX_Control(pDX, IDC_EDIT1, m_f1);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPage1, CPropertyPage)
	//{{AFX_MSG_MAP(CPage1)
	ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
	ON_CBN_SELCHANGE(IDC_COMBO2, OnSelchangeCombo2)
	ON_EN_SETFOCUS(IDC_EDIT1, OnSetfocusEdit1)
	ON_EN_SETFOCUS(IDC_EDIT2, OnSetfocusEdit2)
	ON_EN_UPDATE(IDC_EDIT1, OnUpdateEdit1)
	ON_EN_UPDATE(IDC_EDIT2, OnUpdateEdit2)
	ON_WM_CHAR()
	ON_WM_CANCELMODE()
	ON_WM_CLOSE()
	ON_WM_DESTROY()
	ON_WM_KEYDOWN()
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPage1 message handlers

BOOL CPage1::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	CStatic* pWnd=(CStatic*)GetDlgItem(IDC_STATIC11);
	pWnd->SetWindowText(_T("货币数量"));	
	
	pWnd=(CStatic*)GetDlgItem(IDC_STATIC12);
	pWnd->SetWindowText(_T("货币名称"));	
	
	pWnd=(CStatic*)GetDlgItem(IDC_STATIC_INPUT);
	pWnd->SetWindowText(_T("输入值:"));	

CButton*	p=(CButton*)GetDlgItem(IDC_BUTTON1);
	p->SetWindowText(_T("转换!"));	
	
	pWnd=(CStatic*)GetDlgItem(IDC_STATIC_OUTPUT);
	pWnd->SetWindowText(_T("换算值:"));	
	
	//pWnd=(CStatic*)GetDlgItem(IDC_STATIC13);
	//pWnd->SetWindowText(_T("当改变某数量后,点击另一数量口进行计算"));	

	CComboBox* pCombo = (CComboBox*)GetDlgItem( IDC_COMBO1);
	g_pComboC1=pCombo;
	int nCurSel = pCombo->GetCurSel();
	nCurSel = (nCurSel==CB_ERR) ? 0 : nCurSel ;
	pCombo->ResetContent();
	int nTotal=m_SettingArray.GetSize();
	for(int i=0;i<nTotal;i++)
		pCombo->AddString(m_SettingArray[i]); 
	pCombo->SetCurSel( nCurSel );
	
	m_CurrSel1=nCurSel;

	pCombo = (CComboBox*)GetDlgItem( IDC_COMBO2);
	g_pComboC2=pCombo;
	nCurSel = pCombo->GetCurSel();
	nCurSel = (nCurSel==CB_ERR) ? 1 : nCurSel ;
	pCombo->ResetContent();
	for(i=0;i<nTotal;i++)
		pCombo->AddString(m_SettingArray[i]); 
	
	pCombo->SetCurSel( nCurSel );

	m_CurrSel2=nCurSel;

	CFloatEdit* pWnd2=(CFloatEdit*)GetDlgItem(IDC_EDIT1);
	g_pEdit1=pWnd2;
	CString s=m_SettingArray2[m_CurrSel1];
	pWnd2->SetWindowText(s);	

	CReadOnlyEdit* pWnd3=(CReadOnlyEdit*)GetDlgItem(IDC_EDIT2);//CFloatEdit*
	g_pEdit2=pWnd3;
	s=m_SettingArray2[m_CurrSel2];
	pWnd3->SetWindowText(m_SettingArray2[m_CurrSel2]);	

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


void CPage1::OnSelchangeCombo1() 
{
	
	ReCalcOutputValue();

	UpdateData(FALSE);
}

void CPage1::OnSelchangeCombo2() 
{
	ReCalcOutputValue();

	UpdateData(FALSE);
}

void CPage1::OnSetfocusEdit1() 
{

}

void CPage1::OnSetfocusEdit2() 
{

}

void CPage1::OnUpdateEdit1() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CPropertyPage::OnInitDialog()
	// function to send the EM_SETEVENTMASK message to the control
	// with the ENM_UPDATE flag ORed into the lParam mask.
	
	// TODO: Add your control notification handler code here

}

void CPage1::OnUpdateEdit2() 
{
}



BOOL CPage1::DestroyWindow() 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CPropertyPage::DestroyWindow();
}

LRESULT CPage1::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
	return CPropertyPage::DefWindowProc(message, wParam, lParam);
}

void CPage1::OnCancel() 
{
	// TODO: Add your specialized code here and/or call the base class
	
	CPropertyPage::OnCancel();
}

BOOL CPage1::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CPropertyPage::OnCommand(wParam, lParam);
}

void CPage1::OnOK() 
{
	// TODO: Add your specialized code here and/or call the base class
	
	CPropertyPage::OnOK();
}

void CPage1::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
	
	CPropertyPage::OnChar(nChar, nRepCnt, nFlags);
}

void CPage1::OnCancelMode() 
{
	CPropertyPage::OnCancelMode();
	
	// TODO: Add your message handler code here
	
}

void CPage1::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	
	CPropertyPage::OnClose();
}

void CPage1::OnDestroy() 
{
	CPropertyPage::OnDestroy();
	
	// TODO: Add your message handler code here
	
}

void CPage1::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
	
	CPropertyPage::OnKeyDown(nChar, nRepCnt, nFlags);
}

LRESULT CPage1::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
	return CPropertyPage::WindowProc(message, wParam, lParam);
}

BOOL CPage1::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CPropertyPage::PreTranslateMessage(pMsg);
}

BOOL CPage1::OnSetActive( )
{
	return CPropertyPage::OnSetActive( );
}

void ReCalcOutputValue()
{
	int nCurSel = g_pComboC1->GetCurSel();
	if(nCurSel==CB_ERR)
		{
		return;
		}
	m_CurrSel1=nCurSel;
	nCurSel = g_pComboC2->GetCurSel();
	if(nCurSel==CB_ERR)
		{
		return;
		}
	m_CurrSel2=nCurSel;

	CString s;
	g_pEdit1->GetWindowText(s);	
	double	f;
	int dec;
	f=MyStrToD(s,dec);
	double f1=MyStrToD(m_SettingArray2[m_CurrSel1],dec);
	double f2=MyStrToD(m_SettingArray2[m_CurrSel2],dec);
	f=f*f2/f1;

	TCHAR cc[230];
	wsprintf(cc,_T("%0.6f"),f);
	s=cc;
	g_pEdit2->SetWindowText(s);	
}

double MyStrToD(CString s,int& dec)
{
dec=-1;
int pos=s.Find(_T("."));
if(pos<0)
	return _ttoi(s);
CString s1=s.Left(pos);
int len2=s.GetLength()-pos-1;
CString s2=s.Right(len2);
double d1=_ttoi(s1);
double d2=_ttoi(s2);
int l=len2;
dec=len2;
while(l>0)
	{
	d2=d2/10;
	l--;
	}
return d1+d2;
}

CString MyDtoStr(double d,int& dec,int& sign)
{
if(d<0)
	sign=0;
else
	sign=1;
int d_int=d;
return "";
}

void CPage1::OnButton1() 
{
ReCalcOutputValue();	
}

⌨️ 快捷键说明

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