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 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 was done to reduce the footprint of the sample code, making it easier to trace specific portions of the application.
Note
Some samples, such as this one, have not been modified to reflect the changes in the Visual C++ wizards, libraries, and compiler, but still demonstrate how to complete your desired task.
Security Note: |
---|
This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended. |
To get samples and instructions for installing them:
On the Visual Studio Help menu, click Samples.
For more information, see Visual Studio Samples.
The most recent version and complete list of samples is available online from the Visual Studio 2008 Samples page.
You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. For Express editions of Visual Studio, all samples are located online.
Building and Running the Sample
To build and run the CMNCTRL2 sample
Open the solution cmnctrl2.sln.
On the Build menu, click Build.
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 from the check boxes, radio buttons, and combo boxes available in 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