Chapter 17: Track-Based Controls Visual C++ and MFC Fundamentals
m_Edit.SetWindowText("26");return TRUE; // return TRUE unless you set the focus to a control
}void CSpinEventDlg::OnDeltaposSpin(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
// TODO: Add your control notification handler code here// Declare a pointer to a CSpinButtonCtrl;
CSpinButtonCtrl *Spinner;// Get a pointer to our spin button
Spinner = reinterpret_cast<CSpinButtonCtrl *>(GetDlgItem(IDC_SPIN));// Found out if it is our spin button that sent the message
// This conditional statement appears useless but so what?
if( pNMHDR->hwndFrom == Spinner->m_hWnd )
{
// Get the current value of the spin button
int CurPos = pNMUpDown->iPos;// Convert the value to a string
char StrPos[20];sprintf(StrPos, "%d", CurPos);// Display the value into the accompanying edit box
m_Edit.SetWindowText(StrPos);
}*pResult = 0;
}- Test the application
- Close it and return to MSVC
17.2 The UpDown Control.................................................................................
17.2.1..Overview...............................................................................................
Besides the spin button, Visual C++ ships with an ActiveX control that provides the same
functionality. To use this object, you can add it from the Insert ActiveX Control dialog