You need several new global variables. Declare the following variables at the beginning of the C-language source file:
char MouseText[48]; /* mouse state */
char ButtonText[48]; /* mouse-button state */
char KeyboardText[48]; /* keyboard state */
char CharacterText[48]; /* latest character */
char ScrollText[48]; /* scroll status */
char TimerText[48]; /* timer state */
RECT rectMouse;
RECT rectButton;
RECT rectKeyboard;
RECT rectCharacter;
RECT rectScroll;
RECT rectTimer;
int idTimer; /* timer ID */
int nTimerCount = 0; /* current timer count */
The character arrays hold strings that describe the current state of the keyboard, mouse, and timer. The rectangles keep track of where the strings appear on the screen; this facilitates an invalidation technique. For a description, see “Add the WM_PAINT Case”.
You also need some local variables for the window function. Declare the following variables at the beginning of the MainWndProc window function:
HDC hDC; /* display-context variable */
PAINTSTRUCT ps; /* paint structure */
char HorzOrVertText[12];
char ScrollTypeText[20];
RECT rect;
Add the following variables to the InitInstance function:
HDC hdc;
TEXTMETRIC textmetric;
RECT rect;
int nLineHeight;