Add New Variables

You will need several new variables for this sample application. Place the following statements at the beginning of your C-language source file:

char str[255]; /* general-purpose string buffer */

HCURSOR hSaveCursor; /* handle to current cursor */

HCURSOR hHourGlass; /* handle to hourglass cursor */

BOOL bTrack = FALSE; /* TRUE if left button clicked */

int OrgX = 0, OrgY = 0; /* original cursor position */

int PrevX = 0, PrevY = 0; /* current cursor position */

int X = 0, Y = 0; /* last cursor position */

RECT Rect; /* selection rectangle */

POINT ptCursor; /* x and y coordinates of cursor */

int repeat = 1; /* repeat count of keystroke */

The hSaveCursor and hHourGlass variables hold the cursor handles to be used for the lengthy operation. The bTrack variable holds a Boolean flag indicating whether a selection is in progress. The variables OrgX, OrgY, PrevX, and PrevY hold the original and current cursor positions as a selection is being made. OrgX andB OrgY, along with the variables X and Y hold the original and final coordinates of the selection when the selection process is complete. The ptCursor structure holds the current position of the cursor in the client area. This is updated when the user presses an ARROW key. The Rect structure holds the current dimensions of the client area and is used to make sure the cursor stays within the client area. The repeat variable holds the current repeat count for each keyboard motion.