Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 18: Progress-Based Controls Visual C++ and MFC Fundamentals


To dynamically create a scroll bar control, declare a pointer to CScrollBar using the the
new operator and call its Create() method to initialize it. Here is an example:

class CScrollingDlg : public CDialog
{
// Construction
public:
CScrollingDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CScrollingDlg();

...


// Implementation
protected:

// Generated message map functions
//{{AFX_MSG(CScrollingDlg)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

private:
CScrollBar *Scroller;
};

...


// ScrollingDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Frame3.h"
#include "ScrollingDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CScrollingDlg dialog
Free download pdf