Visual C++ and MFC Fundamentals Chapter 18: Progress-Based Controls
CScrollingDlg::CScrollingDlg(CWnd* pParent /*=NULL*/)
: CDialog(CScrollingDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CScrollingDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
Scroller = new CScrollBar;
}
CScrollingDlg::~CScrollingDlg()
{
delete Scroller;
}
...
/////////////////////////////////////////////////////////////////////////////
// CScrollingDlg message handlers
BOOL CScrollingDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
Scroller->Create(WS_CHILD | WS_VISIBLE,
CRect(200, 15, 320, 148), this, 0x16);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
Practical Learning: Creating Scroll Bars
- On the Controls toolbox, click the Vertical Scroll Bar button and click on the
right side of the picture control. Resize it to have the same height as the picture
control and change its ID to IDC_SCROLL_RED - Add a Control Variable for the new scroll bar control and name it m_ScrollRed
- Add a Static Text under the new scroll bar
CChange its ID to IDC_VAL_RED
Add a CString Value Variable for the new label and name it m_ValRed