A Sample Application: Output

The sample application Output illustrates how to use the WM_PAINT message to draw within the client area, as well as how to create and use drawing tools. The Output application is a simple extension of the Generic application described in the previous chapter. To create the Output application, copy and rename the source files of the Generic application, then make the following modifications:

1.Add new variables.

2.Modify the WM_CREATE case.

3.Add a WM_PAINT case.

4.Modify the WM_DESTROY case.

5.Compile and link the application.

You can find the source files for Output on the sample source code disk.

This sample assumes that you have a color display. If you do not, GDI will simulate some of the color output by “dithering.” Dithering is a method of simulating a color by creating a unique pattern with two or more available colors. On a color monitor that cannot display orange, for example, Windows simulates orange by using a pattern of red and yellow pixels. On a monochrome monitor, Windows represents colors with black, white, and shades of gray, instead of colors.

NOTE:

Rather than typing the code presented in the following sections, you might find it more convenient to simply examine and build the sample source files provided on the sample disks.