Graphics Reference
In-Depth Information
state is initialized in the OnInitDialog() function. The application state
OnInitDialog() . Recall
that the OnInitDialog()
function should implement the
SystemInitialization()
functionality.
is updated during the button event service routine (A3).
Support for the button GUI element (B). The event service routine is
declared at label B1 in the TutorialDlg.h file. At label B2, we register
the ON _ BN _ CLICKED (on button click) event and associate the GUI element
ID _ BTN _ ADD with the OnBnClickedBtnAdd() routine.
This process reg-
ID _ BTN _ ADD . See Figure 2.6.
This is the GUI ID for the
“Click to Add” button.
isters the routine as a callback function for the click event on the button.
The event service routine is implemented at label B3, where we update the
application state and display the updated information to the output echo
area.
Output GUI element (C). At label C1, we define the variable m _ EchoText ,
and at label C2, this variable is bound to the GUI element IDC _ ECHO _ AREA .
Notice that before the binding statement at label C2, m _ EchoText is sim-
IDC _ ECHO _ AREA . See Fig-
ure 2.6. This is the GUI ID for
the output echo area.
ply just another instance variable. However, after the statement at C2,
m _ EchoText becomes the control variable of the IDC _ ECHO _ AREA .After
the application state is updated in the button event service routine, at label
C3, the m _ EchoText is set with the updated application state. At this point,
the value of the m _ EchoText control variable is different from the state in-
formation presented in the IDC _ ECHO _ AREA . The statement at C4 flushes
the content of m _ EchoText to the GUI element to ensure consistency.
Tutorial 2.3. More with Control Variables
Tutorial 2.3.
Project Name
MFC _ SliderControls
Goal. Understand that control variables can be complex data types and
demonstrate working with control variables of input GUI elements.
Approach. Work with slider bars, a fairly complex GUI element.
Figure 2.7 is a screenshot of running Tutorial 2.3. This application is basically
Tutorial 2.2 with two extra slider bar sets. From the GUI layout, we see that
each slider bar set actually consists of three GUI elements: the label, the slider
bar, and the echo area, as shown in Table 2.3. We worked with labels and the
output echo area in Tutorial 2.2. In this tutorial, we will concentrate on working
with the slider bar and servicing of slider bar events. When we examine the
development environment, we see the familiar source code structure. Once again,
we will concentrate on TutorialDlg.h/.cpp . Listing 2.7 highlights the new
programming code fragments that are associated with the slider bars.
Figure 2.7.
Tutorial 2.3.
 
Search WWH ::




Custom Search