Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

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



  1. Click OK or Finish

  2. In the same way, add a Control variable for the IDC_SPIN_GREEN control named
    m_SpinGreen and a Control variable for the IDC_SPIN_BLUE control named
    m_SpinBlue

  3. For MSVC 6, click the Message Maps property page. In the Member Functions list
    box, click OnInitDialog and click Edit Code


In the OnInitDialog event of the CcolorPreviewDlg class, set the range of the spin
buttons to (0, 255) and set its initial value to 192

BOOL CColorPreviewDlg::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_SpinRed.SetRange(0, 255);
m_SpinGreen.SetRange(0, 255);
m_SpinBlue.SetRange(0, 255);

m_SpinRed.SetPos(192);
m_SpinGreen.SetPos(192);
m_SpinBlue.SetPos(192);

PreviewColor = RGB(192, 192, 192);

return TRUE; // return TRUE unless you set the focus to a control
}


  1. Execute the application. Test the spin buttons and make sure they are working fine.
    Then close the dialog box and return to MSVC

Free download pdf