Visual C++ and MFC Fundamentals Chapter 17: Track-Based Controls
- After testing the spin buttons, close the dialog box and return to MSVC
- Now we will implement an exercise that exploits the pNMHDR argument of the
UDN_DELTAPOS message.
Create a new Dialog-based application named SpinEvent without the About Box - Delete the TODO line
- Change the caption of the Cancel button to Close
- Add an Edit Box control to the top-left section of the dialog box and change its
ID to IDC_EDIT - Add a Spin button to the right side of the edit box and change only its ID to
IDC_SPIN - Add a Control variable for the edit box and name it m_Edit
- Add a Control variable for the spin button and name it m_Spin
- As done in the previous exercise, fire the UDN_DELTAPOS event for the spin
button. - Change the OnInitDialog event of the dialog box and implement the event of the
UDN_DELTAPOS message as follows:
BOOL CSpinEventDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
m_Spin.SetRange(12, 185);