Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

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



  1. Close it and return to MSVC


17.3.2..Slider Creation.....................................................................................


To provide a slider to an application, from the Controls toolbox, click the Slider button

and click the desired area on the dialog box or the form.

To programmatically create a slider, declare a pointer to CSliderCtrl using the new
operator. To initialize the control, call its Create() method. Here is an example:

BOOL CDlgSlide::OnInitDialog()
{
CDialog::OnInitDialog();

// TODO: Add extra initialization here
CSliderCtrl *TrackBar = new CSliderCtrl;

TrackBar->Create(WS_CHILD | WS_VISIBLE,
CRect(15, 20, 222, 50), this, 0x14);

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

Practical Learning: Creating a Slider



  1. On the Controls toolbox, click the Slider button and click in lower-left section
    of the dialog box

Free download pdf