4.2.2 Adding New Variables

Since you will need several new global variables, declare them 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 identifier    */
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, and make possible the invalidation technique explained in Section 4.2.15, “Adding a WM_PAINT Case.”

Since you will also need some local variables for the window procedure, declare them at the beginning of MainWndProc, as follows:

HDC hDC;                  /* handle of device context     */
PAINTSTRUCT ps;           /* paint structure              */
char ScrollTypeText[20];
RECT rect;

Add the following variables to the InitInstance function:

HDC             hDC;
TEXTMETRIC      textmetric;
RECT            rect;
int             nLineHeight;