Graphics Reference
In-Depth Information
Front-End GUI Layout Design
In all of the tutorials so far, the GUI elements are defined to be contained inside
the default application window. Figure 2.12 shows the structure of the GUI el-
ements in Tutorial 2.8. Notice that the GUI elements for controlling the circle
radius are defined inside a separate container window (GUI ID: IDD _ CONTROLS
_ CHILDDLG ). As illustrated in Figure 2.12, a placeholder (GUI ID: IDC _ PLACE
HOLDER ) is defined on the main application window for placing the container win-
dow.
Back-End Implementation
On the back end, we must define a new data type to support the new container win-
dow. Notice that our main application window is also an example of a container
window, where the main application window is a GUI element that is defined to
contain other GUI elements. We have been defining the CTutorialDlg class as
the data type to support our main application window. When we examine the im-
plementations (e.g., Listing 2.9 of Tutorial 2.5), we observe that CTutorialDlg
is a subclass of the MFC CDialog class to take advantage of the vast predefined
behaviors. Based on this experience, we can define a new data type for the new
container window. Listing 2.11 shows that similar to the CTutorialDlg class,
the new CCircleRadiusControls class is also a subclass of the MFC CDialog
class. This means that all of our previous experiences can be applied. We observe
the following.
Window initialization (A). All container objects must initialize their con-
tents. As we learned previously, the OnInitDialog() function will be in-
voked during the initialization of the window. In Listing 2.11, we observe
the declaration (A1) and implementation (A2) of this function.
Control variables (B). We need to have references to the slider bar and the
checkbox during run time. As we have seen many times, the variables are
defined at label B1, bound to the GUI elements at label B2, and initialized
at label B3. In this tutorial, we are using the slider bar data type defined in
Tutorial 2.6 (B1). Notice that even without any services, the numeric echo
area reflects the knob positions correctly.
Event services (C). The service of the checkbox event is established in fa-
miliar procedure: declaration of the service routine at label C1, registration
of the event at label C2, and implementation at label C3.
With the CCircleRadiusControls data type definition, we can now define con-
trol variables for the container window in our main window. We have seen the
Search WWH ::




Custom Search