Graphics Reference
In-Depth Information
GUI Element
GUI ID
Control Variable
IDC
_
V
_
SLIDER
_
BAR
m
_
VSliderBar
Slider Bars
IDC
_
H
_
SLIDER
_
BAR
m
_
HSliderBar
Slider Bar Labels
Vertical Bar
−
Horizontal Bar
−
IDC
_
V
_
SLIDER
_
ECHO
m
_
VSliderEcho
Slider Bar Echo Areas
IDC
_
H
_
SLIDER
_
ECHO
m
_
HSliderEcho
Table 2.3.
The elements of Tutorial 2.3.
•
Slider bar echo control variables (A).
We see declaration of the variables
at label A1. Note that
m
_
HSliderEcho
is simply another variable until the
DDX
_
Text
macro call at label A2. After this macro call,
m
_
HSliderEcho
becomes the control variable for
IDC
_
H
_
SLIDER
_
ECHO
GUI element. These
control variables are initialized at label A3.
•
Slider bar control variables (B).
We see the declaration of the variables
at label B1. These will be the control variables for the slider bars. Notice
the
CSliderCtrl
data type. MFC predefines data types to support every
type of GUI element (e.g.,
CButton
for button GUI elements,
CComboBox
for combo-box GUI elements). At label B2, these variables are bound
to the corresponding slider bar GUI elements. At label B3, during the
initialization
OnInitDialog()
function call, we initialize the max, min,
and initial position of the slider bar knobs. After the initialization func-
tion calls, the values of the control variables (e.g.,
m
_
VSliderBar
)be-
come out-of-sync with the state of the corresponding GUI element (e.g.,
IDC
_
V
_
SLIDER
_
BAR
). The
false
parameter to the
UpdateData()
function
call at label B4 flushes the control variables' values onto their correspond-
ing GUI elements.
class
CTutorialDlg :
public
CDialog {
Source file.
TutorialDlg.h/cpp
file in
the
Source
and
Header
files folders of the
MFC
_
SliderControls
project.
.
// removed content similar to that from
//
Listing 2.6 (Tutorial 2.2)
.
A1:
CString m
_
HSliderEcho, m
_
VSliderEcho;
B1:
CSliderCtrl m
_
VSliderBar, m
_
HSliderBar;
C1:
afx
_
msg void
OnHScroll(UINT nSBCode, UINT nPos, CScrollBar
*
pScrollBar);
afx
_
msg void
OnVScroll(UINT nSBCode, UINT nPos, CScrollBar
*
pScrollBar);
};
Listing 2.7.
CTutorialDlg
class (Tutorial 2.3).
Search WWH ::
Custom Search