Graphics Reference
In-Depth Information
As in all previous tutorials, all changes in programming code are localized to the
TutorialDlg.h/.cpp files. Listing 2.8 highlights the changes from the previous
tutorial:
Application state (A). Because the application counts the number of sec-
onds elapsed, we must define (A1) and initialize (A2) a counter that we can
count in seconds. This counter will be updated in the timer service routine
in C4.
Mouse and timer echo (B). These are simple output echo set-ups. As we
saw in previous tutorials, we must declare the variables (B1) and associate
the variables with the GUI IDs (B2). The content of these echo regions are
updated during corresponding mouse and timer service routines.
Application timer events (C). Label C1 shows the declaration of the OnTi
mer() service function. During the initialization in OnInitDialog() ,at
label C2, the alarm is set to go off every 1000 milliseconds (or 1 second). At
label C3, we call the ON _ WM _ TIMER (on window timer) macro to register for
the timer event. We do not see any callback function during the registration.
Once again, the OnTimer() function is defined by the MFC CDialog class,
and we will override it to customize to our application. The timer service
routine is defined at label C4. This function is invoked once every second.
We service the timer event by incrementing m _ Seconds and echoing the
new value to the defined echo area.
Mouse events (D). Just like the timer in this tutorial and slider bars from
previous tutorials, the CDialog class has default support for mouse events.
We know we must override the functions (D1), register for the events (D2),
Hardware coordinate. The
coordinate system where the
top left is the origin with the y -
axis increasing downward and
the x -axis increasing to the
right.
and implement the functions (D3, D4). Notice that the mouse positions
are passed in the CPoint structure. If you run the tutorial and move the
mouse around in the application window, notice that the mouse positions
are defined relative to the top-left corner (the origin is located at the top-left
corner).
Tutorial 2.5. Input/output GUI elements.
Tutorial 2.5.
Project Name
MFC _ UpdateGUI
Goal. Experience working with GUI elements that serve both input (from
user to application) and output (from application to user) functions for the
application.
Approach. Continue with the previous tutorial, where this tutorial will
allow both the application and the user to control the slider bars.
Search WWH ::




Custom Search