?? cspin.cpp
字號:
#include "StdAfx.h"
#include "CNumEdit.h"
#include "CSpin.h"
IMPLEMENT_DYNAMIC(CSpin,CSpinButtonCtrl)
BEGIN_MESSAGE_MAP(CSpin,CSpinButtonCtrl)
//{{AFX_MSG_MAP(CSpin)
//}}AFX_MSG_MAP
ON_NOTIFY_REFLECT(UDN_DELTAPOS, OnDeltaPos)
END_MESSAGE_MAP()
// Class CSpin
CSpin::CSpin ()
{
m_delta = 1;
}
void CSpin::Change (int steps)
{
CWnd* b = GetBuddy();
CNumEdit* edit = dynamic_cast<CNumEdit*>(b);
ASSERT(edit); // cast falied
float fDelta = steps*m_delta;
float f = edit->GetValue();
// This messy bit of code gets around a floating point resolution problem.
// For example, if your step is -1 and m_Delta is .1, you would end up
// with -1.49xxx e-9 and it would never set the control to zero. The old
// 0 != 0 problem.
if( f == -fDelta )
f = 0;
else
f += fDelta;
edit->SetValue(f);
}
void CSpin::OnDeltaPos (NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
DWORD bWrap = (GetStyle() & UDS_WRAP);
if ((pNMUpDown->iPos <= pNMUpDown->iDelta) ||
(pNMUpDown->iPos >= 1000 - pNMUpDown->iDelta)) pNMUpDown->iPos = 500;
Change(pNMUpDown->iDelta);
*pResult = 0;
}
void CSpin::SetDelta (float x)
{
m_delta = x;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -