Add the WM_CREATE Case

You must create the drawing tools to be used in Output's client area before any drawing is carried out. Since you need to create these tools only once, a convenient place to do so is in the WM_CREATE message. Add the following statements to the MainWndProc function:

case WM_CREATE:

/* Create the brush objects */

hRedBrush = CreateSolidBrush(RGB(255, 0, 0));

hGreenBrush = CreateSolidBrush(RGB( 0, 255, 0));

hBlueBrush = CreateSolidBrush(RGB( 0, 0, 255));

/* Create the “—-” pen */

hDashPen = CreatePen(PS_DASH, /* style */

1, /* width */

RGB(0, 0, 0)); /* color */

/* Create the “...” pen */

hDotPen = CreatePen(PS_DOT, /* style */

1, /* width */

RGB(0, 0, 0)); /* color */

break;

The CreateSolidBrush functions create the solid brushes to be used to fill the rectangle, the ellipse, and the circle that Output draws on the screen in response to the WM_PAINT message. The CreatePen functions create the dotted and dashed lines used to draw borders.