Share via


CMNCTRL2 Sample: Demonstrates Common Control MFC Classes, Part 2

The CMNCTRL2 sample illustrates how to use the following common control MFC classes: CProgressCtrl, CSliderCtrl, and CSpinButtonCtrl. It shows how the controls are created and how to change the controls by using many of the different available styles.

CMNCTRL2 is the result of replacing the original CMNCTRLS sample with two smaller projects: CMNCTRL1 (tree, toolbar, date and time picker, month calendar, and animate controls) and CMNCTRL2 (progress, up/down, and slider controls). This design reduces the footprint of the sample code, which makes it easier to trace specific portions of the application.

Note

This sample may not exactly demonstrate some features of the Visual C++ wizards, libraries, and compiler, but it still shows how to complete the intended task.

Security noteSecurity Note
This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To get samples and instructions for installing them:

To access samples from Visual Studio

  • On the Help menu, click Samples.

    By default, these samples are installed in drive:\Program Files\Microsoft Visual Studio 10.0\Samples\.

  • For the most recent version of this sample and a list of other samples, see Visual Studio Samples on the MSDN Web site.

Building and Running the Sample

To build and run the CMNCTRL2 sample

  1. Open cmnctrl2.sln.

  2. On the Build menu, click Build.

  3. On the Debug menu, click Start Without Debugging.

When you run CMNCTRL2, select the tab for the control you want to activate. Select the styles and views by using the check boxes, radio buttons, and combo boxes on the different property pages. Notice how each option changes the behavior or appearance of the control being displayed.

Keywords

This sample demonstrates the following keywords:

CBitmap::LoadBitmap; CEdit::Clear; CEdit::GetLineCount; CEdit::LineIndex; CEdit::LineLength; CEdit::ReplaceSel; CEdit::SetSel; CFileDialog::DoModal; CFileDialog::GetPathName; CGdiObject::DeleteObject; CSpinButtonCtrl::GetBuddy; CString::GetBufferSetLength; CString::GetLength; CString::Left; CString::LoadString; CString::ReleaseBuffer; CWinApp::LoadIcon; CWnd::GetClientRect; CWnd::GetWindowRect; CWnd::SetWindowPos; CWnd::SetWindowText; DeleteItem; CWnd::DestroyWindow; CWnd::EnableWindow; GetCursorPos; GetDlgItem; GetParent; GetWindowLong; GetWindowRect; InvalidateRect; LoadIcon; MAKELONG; MessageBeep; ReleaseCapture; ScreenToClient; SetCapture; SetWindowLong; SetWindowPos; UpdateWindow; WindowProc; mbstowcs; rand; srand; time; wsprintf

See Also

Other Resources

MFC Samples