📄 page2.cpp
字号:
// Page2.cpp : implementation file
//
#include "stdafx.h"
#include "Currency_CE.h"
#include "Page2.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CString g_sInstallDir;
extern CStringArray m_SettingArray;
extern CStringArray m_SettingArray2;
extern void ReCalcOutputValue();
extern CComboBox* g_pComboC1;
extern CComboBox* g_pComboC2;
/////////////////////////////////////////////////////////////////////////////
// CPage2 property page
IMPLEMENT_DYNCREATE(CPage2, CPropertyPage)
CPage2::CPage2() : CPropertyPage(CPage2::IDD)
{
//{{AFX_DATA_INIT(CPage2)
//}}AFX_DATA_INIT
}
CPage2::~CPage2()
{
}
void CPage2::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPage2)
DDX_Control(pDX, IDC_EDIT1, m_f3);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPage2, CPropertyPage)
//{{AFX_MSG_MAP(CPage2)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_CBN_SELCHANGE(IDC_COMBO21, OnSelchangeCombo21)
ON_EN_SETFOCUS(IDC_EDIT1, OnSetfocusEdit1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPage2 message handlers
BOOL CPage2::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// TODO: Add extra initialization here
CStatic* pWnd=(CStatic*)GetDlgItem(IDC_STATIC21);
pWnd->SetWindowText(_T("1 美元 = "));
pWnd=(CStatic*)GetDlgItem(IDC_BUTTON1);
pWnd->SetWindowText(_T("保存"));
pWnd=(CStatic*)GetDlgItem(IDC_STATIC22);
pWnd->SetWindowText(_T("请指定货币名称,并设定与\r\n美元的比价,然后点击按钮\r\n\"保存\"来存盘。在此还可以\r\n添加这里没有的货币。"));
CComboBox* pCombo = (CComboBox*)GetDlgItem( IDC_COMBO21);
int nCurSel = pCombo->GetCurSel();
nCurSel = (nCurSel==CB_ERR) ? 1 : nCurSel ;
pCombo->ResetContent();
int nTotal=m_SettingArray.GetSize();
for(int i=0;i<nTotal;i++)
pCombo->AddString(m_SettingArray[i]);
pCombo->SetCurSel( nCurSel );
CFloatEdit* pEdit=(CFloatEdit*)GetDlgItem(IDC_EDIT1);
CString s=m_SettingArray2[nCurSel];
pEdit->SetWindowText(s);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPage2::OnButton1()
{
CFloatEdit* pWnd2=(CFloatEdit*)GetDlgItem(IDC_EDIT1);
CString s="";
CString s2="";
pWnd2->GetWindowText(s);
if(s=="")return;
CComboBox* pCombo = (CComboBox*)GetDlgItem( IDC_COMBO21);
int nCurSel = pCombo->GetCurSel();
if(nCurSel==CB_ERR)
{
pCombo->GetWindowText(s2);
if(s2=="")
return;
m_SettingArray2.Add(s);
m_SettingArray.Add(s2);
pCombo->ResetContent();
int nTotal=m_SettingArray.GetSize();
for(int i=0;i<nTotal;i++)
pCombo->AddString(m_SettingArray[i]);
pCombo->SetCurSel(nTotal-1);
g_pComboC1->AddString(m_SettingArray[nTotal-1]);
g_pComboC2->AddString(m_SettingArray[nTotal-1]);
}
else
{
if(nCurSel<m_SettingArray2.GetSize()&&nCurSel>-1)
m_SettingArray2[nCurSel]=s;
else
return;
}
int nTotal=m_SettingArray.GetSize();
int i=0;
DWORD dwFileLen, dwFileLen1;
HANDLE hFile;
hFile = ::CreateFile(g_sInstallDir+_T("\\Currency.dat\0"),
GENERIC_WRITE |GENERIC_READ, // we need both read and write access
FILE_SHARE_READ, // allow read access for others
NULL, // security attributes
CREATE_ALWAYS, // always create new file
0, // file attribute
NULL); // handle to a template file
if (hFile)
{
for(i=0;i<nTotal;i++)
{
::WriteFile(hFile, (const unsigned short*)m_SettingArray[i],
_tcslen(m_SettingArray[i])*2,&dwFileLen1,0);
::WriteFile(hFile, _T("="),2,&dwFileLen1,0);
::WriteFile(hFile, (const unsigned short*)m_SettingArray2[i],
_tcslen(m_SettingArray2[i])*2,&dwFileLen1,0);
::WriteFile(hFile,_T("\r\n"),4,&dwFileLen1,0);
ReCalcOutputValue();
}
CloseHandle(hFile);
}
else
{
AfxMessageBox(_T("Cannot find file,exit application! "));
SendMessage(WM_CLOSE);
}
}
void CPage2::OnSelchangeCombo21()
{
CComboBox* pCombo = (CComboBox*)GetDlgItem( IDC_COMBO21);
int nCurSel = pCombo->GetCurSel();
nCurSel = (nCurSel==CB_ERR) ? 1 : nCurSel ;
CFloatEdit* pWnd2=(CFloatEdit*)GetDlgItem(IDC_EDIT1);
CString s=m_SettingArray2[nCurSel];
pWnd2->SetWindowText(s);
}
void CPage2::OnSetfocusEdit1()
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -