MFC Step-by-Step Guide

Tutorial 8

Grouping of GUI Elements


GOAL: Group sections of GUI elements as an advantage of organizing the user interface
PREREQUISITES: Tutorial 1 with the 'MFC Library1' library added as a dependant and included 'MFC_Library1.h' at the bottom of 'stdafx.h'

Creating a Placeholder
  1. Drag a Static Text to the dialog window, inside the Properties window, change
    1. ID to "IDC_PLACEHOLDER"
    2. Caption to "Placeholder for control group"
    3. Align Text to Center
    4. Border to True
Creating a Container
  1. Inside the Resource View, Right-Click the Dialog folder and Click Add Resource...
  2. With the new resource window selected, inside the Properties window, change
    1. ID to "IDD_CONTROLS_CHILDDLG"
    2. Border to None
    3. Style to Child
    4. System Menu to False
    5. Title Bar to False
    Figure 8.1 - Placeholder
    Figure 8.1 - Placeholder
Connecting Class to Resource
  1. Inside the Solution Explorer, Right-Click the Project (MFC_GroupControls) folder and Click Add Class...
  2. Inside the Add Class window, select
    1. Categories to Visual C++
    2. Template to Generic C++ Class
    Figure 8.2 - Add Class
    Figure 8.2 - Add Class
  3. Inside the Generic C++ Class Wizard window, change
    1. Class Name to "CCircleRadiusControls"
    2. .h file and .cpp file will be inserted automatically
    3. Base Class to CDialog
    4. Access to public
    Figure 8.3 - C++ Class Wizard
    Figure 8.3 - Generic C++ Class Wizard
  4. In 'TutorialDlg.h', add
    1. #include "CircleRadiusControls.h" to the top
    2. CCircleRadiusControls m_circle_controls; as a private variable
  5. Inside 'TutorialDlg.cpp', inside OnInitDialog() function, add
       ...
       ReplaceDialogControl(*this, IDC_PLACEHOLDER, m_circle_controls, IDD_CONTROLS_CHILDDLG);
       ...
    ReplaceDialogControl(...) found in 'UtilityFunctions.cpp' as part of the MFC Library 1


» Written by William Frankhouser (wjf2@washington.edu)
» Advised by Kelvin Sung (ksung@washington.edu) as part of the project sponsored by the National Science Foundation under Grant No. 0442420. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.
» Produced in the "Essential Concepts for Building Interactive Computer Graphics Applications", A.K. Peters, Ltd.