Visual C++ and MFC Fundamentals Chapter 17: Track-Based Controls
BOOL CSpinDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CSpinButtonCtrl *SpinCtrl = new CSpinButtonCtrl;
SpinCtrl->Create(WS_CHILD | WS_VISIBLE, CRect(60, 10, 80, 35), this, 0x128);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
Practical Learning: Creating Spin Buttons
Here is the dialog box as we will design it:
- On the Controls toolbox, click the Edit Box button and click under the picture
control and on the left side of the dialog box - On the Control toolbox, click the Spin button and click to the right side of the
IDC_EDIT1 control on the dialog box - While the spin button is still selected, press and hold Ctrl. Click the previously added
edit box and release Ctrl - Press Ctrl + C to copy and press Ctrl + V to paste
- Move the newly two pasted controls to the right
- Press Ctrl + V to paste again and move the new controls to the right side of the
others - Using the properties window, change the identifiers of the controls, from left to right,
to IDC_EDIT_RED, IDC_SPIN_RED, IDC_EDIT_GREEN,
IDC_SPIN_GREEN, IDC_EDIT_BLUE, and IDC_SPIN_BLUE