Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

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



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

  2. Add a Control Variable for the new scroll bar control and name it m_ScrollRed

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

Free download pdf