4.2.1 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 the wsprintf function, the Windows version of the C run-time function sprintf. The wsprintf function copies a formatted string to a buffer; you can then pass the buffer address as an argument to the TextOut function. 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.