📄 strcurrency.cpp
字号:
// StrCurrency.cpp: implementation of the CStrCurrency class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "DerivedDialogTest.h"
#include "StrCurrency.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CStrCurrency::CStrCurrency()
{
m_Str = "";
m_ldCurrency = 0.0;
m_Currency.SetCurrency(0,0);
}
CStrCurrency::~CStrCurrency()
{
}
CStrCurrency::operator long double()
{
return m_ldCurrency;
}
CStrCurrency::operator CString()
{
return m_Str;
}
CStrCurrency::operator COleCurrency()
{
return m_Currency;
}
long double CStrCurrency::operator =(long double ldVal )
{
m_Currency.m_cur.int64 = (__int64)(ldVal * 10000.0);
m_ldCurrency = ldVal;
MakeStr();
return ldVal;
}
COleCurrency CStrCurrency::operator =(COleCurrency ocVal )
{
m_Currency = ocVal;
MakeStr();
MakeLd();
return m_Currency;
}
CString CStrCurrency::operator =(CString strVal)
{
m_Currency.ParseCurrency(strVal);
if(m_Currency.GetStatus() != COleCurrency::valid)
{
m_ldCurrency = 0.0;
m_Str = "Inv醠ido";
}
else
{
MakeLd();
MakeStr();
}
return m_Str;
}
void CStrCurrency::MakeStr()
{
int nSize;
CString strUfmt;
strUfmt.Format("%f",m_ldCurrency);
nSize = GetCurrencyFormat(LOCALE_SYSTEM_DEFAULT,0,strUfmt,NULL,NULL,0);
GetCurrencyFormat(LOCALE_SYSTEM_DEFAULT,0,strUfmt,NULL,m_Str.GetBuffer(nSize),nSize);
m_Str.ReleaseBuffer(nSize);
}
void CStrCurrency::MakeLd()
{
m_ldCurrency = m_Currency.m_cur.int64 / 10000.0;
}
CStrCurrency::CStrCurrency(CStrCurrency &other)
{
*this = other;
}
const CStrCurrency& CStrCurrency::operator =(const CStrCurrency& other)
{
m_Currency = other.m_Currency ;
m_ldCurrency = other.m_ldCurrency ;
m_Str = other.m_Str ;
return *this;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -