Spin Control
C / C++ / MFC
2
Posts
2
Posters
0
Views
1
Watching
-
How to make spin control work with double or float data types?
-
How to make spin control work with double or float data types?
This is fairly easy to do. Do the following steps: 1: Set the range of value: If you want a step of 0.1 and a min equal to 0.0 and a max equal to 10.0, the range of value of your spin control must be 0-100 (100 = 10/0.1) 2: Add a message handler for WM_VSCROLL
void CDialog::OnVScroll ( UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
if (nSBCode == SB_ENDSCROLL)
return ;if (pScrollBar->GetDlgCtrlID() === IDC\_SPIN) // your spin ID here { CString strValue ; strValue.Format("%3.1f", (double)(nPos / 10.0)) ; ((CSpinButtonCtrl\*)pScrollBar)->GetBuddy()->SetWindowText(strValue) ; }
}
Roger Allen Sonork 100.10016 If I'm not breathing, I'm either dead or holding my breath. A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?