How the Input Application Displays Output

The Input application responds to input messages by displaying text that indicates the type of input message. It uses some simple functions to format and display the output.

To create a formatted string, use wsprintf, the Windows version of the C run-time function sprintf. The Windows wsprintf function copies a formatted string to a buffer; you can then pass the buffer address as an argument to the TextOut function. In small-model applications, such as the sample applications described in this guide, be careful when using the wsprintf function; the buffer you specify must be defined within the application's data segment or stack. The following example shows how to create a formatted string:

char MouseText[48];

.

.

.

wsprintf(MouseText, “WM_MOUSEMOVE: %x, %d, %d”, wParam,

LOWORD(lParam), HIWORD(lParam));

This example copies the formatted string to the MouseText array. The array is declared a local variable so that it can be passed to the wsprintf function.