AN INTRODUCTION TO GDI

To paint the client area of your window, you use Windows' Graphics Device Interface (GDI) functions. (A full discussion of GDI is in Chapters 11–15.) Windows provides five GDI functions for writing text strings to the client area of the window. We've already encountered the DrawText function in Chapter 1, but the most popular text output function by far is TextOut. This function has the following format:

TextOut (hdc, x, y, lpsString, nLength) ;

TextOut writes a character string to the display. The lpsString parameter is a long (or far) pointer to the character string, and nLength is the length of the string. The x and y parameters define the starting position, in ”logical coordinates,“ of the character string in the client area. The hdc parameter is a ”handle to a device context,“ and it is an important part of GDI. Virtually every GDI function requires this handle as the first parameter to the function.