Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 17: Track-Based Controls



  1. After testing the spin buttons, close the dialog box and return to MSVC

  2. 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

  3. Delete the TODO line

  4. Change the caption of the Cancel button to Close

  5. Add an Edit Box control to the top-left section of the dialog box and change its
    ID to IDC_EDIT

  6. Add a Spin button to the right side of the edit box and change only its ID to
    IDC_SPIN

  7. Add a Control variable for the edit box and name it m_Edit

  8. Add a Control variable for the spin button and name it m_Spin

  9. As done in the previous exercise, fire the UDN_DELTAPOS event for the spin
    button.

  10. 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);
Free download pdf