Visual C++ and MFC Fundamentals Chapter 18: Progress-Based Controls
CRect RectPreview;
// Create a brush to use
CBrush BrushColor(RGB(ColorRed, ColorGreen, ColorBlue));
// Get the location and dimensions of the picture control
m_Preview.GetWindowRect(&RectPreview);
// Select the brush
CBrush *pOldBrush = dc.SelectObject(&BrushColor);
// Use the client coordinates
ScreenToClient(&RectPreview);
// Draw or update the background of the picture control
dc.Rectangle(&RectPreview);
// Restore the previous brush
dc.SelectObject(pOldBrush);
}
- In the source file, initialize each member variable with 192
CPreviewerDlg::CPreviewerDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPreviewerDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
ColorRed = 192;
ColorGreen = 192;
ColorBlue = 192;
}
- Save All
18.4.3..Creating a Scroll Bar Control............................................................
The scroll bars we have added to the view classes above are inherently provided by the
operating system and can sometimes transparently added to a view of an application with
little of your intervention. Alternatively, Visual C++ provides two scroll bar controls you
can add to a dialog box or a form and positioned anywhere you judge necessary.
To add a vertical scroll bar control to a dialog box or a form at design time, on the
Controls toolbox, click the Vertical Scroll Bar button and click an area on the host.
In the same way, to add a horizontal scroll bar control, on the Controls toolbox, click the
Horizontal Scroll Bar button and click the body of dialog box or that of the form.
After adding the control, it assumes a default size. You can resize it as you would do with
any other control. Here is an example: