Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

79 lines
1.5 KiB
C++

// MySpin.cpp : implementation file
//
#include "stdafx.h"
#include "MySpin.h"
#include "globalFunc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMySpin
CMySpin::CMySpin(double nDelta)
{
m_nDelta = nDelta;
m_bText = FALSE;
}
CMySpin::~CMySpin()
{
}
BEGIN_MESSAGE_MAP(CMySpin, CSpinButtonCtrl)
//{{AFX_MSG_MAP(CMySpin)
ON_NOTIFY_REFLECT(UDN_DELTAPOS, OnDeltapos)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMySpin message handlers
void CMySpin::OnDeltapos(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
CWnd *pWnd = GetBuddy();
if(pWnd){
CString csTmp;
pWnd->GetWindowText(csTmp);
if(m_bText){
if(pNMUpDown->iDelta > 0)
csTmp = GlobalFunc::PlusString2(csTmp, 1, TRUE);
else
csTmp = GlobalFunc::PlusString2(csTmp, -1, TRUE);
pWnd->SetWindowText(csTmp);
return;
}
int lower, upper;
GetRange(lower, upper);
double nVal = _tstof(csTmp);
if(pNMUpDown->iDelta > 0)
nVal = nVal + m_nDelta;
else{
nVal = nVal - m_nDelta;
if(nVal < 0)
nVal = 0;
}
if(nVal > upper || nVal < lower)
return;
if(m_nDelta < 1 && m_nDelta >= 0.1)
csTmp.Format(_T("%.1f"), nVal);
else if(m_nDelta < 0.1 && m_nDelta >= 0.01)
csTmp.Format(_T("%.2f"), nVal);
else if(m_nDelta >= 1)
csTmp.Format(_T("%.0f"), nVal);
pWnd->SetWindowText(csTmp);
}
*pResult = 0;
}