Modify the WM_COMMAND Case

You need to change the WM_COMMAND case to support the Bitmap, Pattern, and Mode menus. In the window function, replace the WM_COMMAND case with the following statements:

case WM_COMMAND: /* message: Windows command */

switch (wParam) {

case IDM_ABOUT:

lpProcAbout = MakeProcInstance (About, Inst);

DialogBox (hInst,

“AboutBox”,

hWnd,

lpProcAbout);

FreeProcInstance (lpProcAbout);

break;

case IDM_BITMAP1:

wPrevItem = wPrevBitmap;

wPrevBitmap = wParam;

GetObject(hBitmap1, 16, (LPSTR) &Bitmap);

SelectObject(hMemoryDC, hBitmap1);

break;

case IDM_BITMAP2:

wPrevItem = wPrevBitmap;

wPrevBitmap = wParam;

GetObject(hBitmap2, 16, (LPSTR) &Bitmap);

SelectObject(hMemoryDC, hBitmap2);

break;

case IDM_BITMAP3:

wPrevItem = wPrevBitmap;

wPrevBitmap = wParam;

GetObject(hBitmap3, 16, (LPSTR) &Bitmap);

hOurBitmap = SelectObject(hMemoryDC, hBitmap3);

break;

case IDM_PATTERN1:

wPrevItem = wPrevPattern;

wPrevPattern = wParam;

DeleteObject(hBrush);

hBrush = CreatePatternBrush(hPattern1);

InvalidateRect(hWnd, (LPRECT) NULL, TRUE);

UpdateWindow(hWnd);

break;

case IDM_PATTERN2:

wPrevItem = wPrevPattern;

wPrevPattern = wParam;

DeleteObject(hBrush);

hBrush = CreatePatternBrush(hPattern2);

InvalidateRect(hWnd, (LPRECT) NULL, TRUE);

UpdateWindow(hWnd);

break;

case IDM_PATTERN3:

wPrevItem = wPrevPattern;

wPrevPattern = wParam;

DeleteObject(hBrush);

hBrush = CreatePatternBrush(hPattern3);

InvalidateRect(hWnd, (LPRECT) NULL, TRUE);

UpdateWindow(hWnd);

break;

case IDM_PATTERN4:

wPrevItem = wPrevPattern;

wPrevPattern = wParam;

DeleteObject(hBrush);

hBrush = CreatePatternBrush(hPattern4);

InvalidateRect(hWnd, (LPRECT) NULL, TRUE);

UpdateWindow(hWnd);

break;

case IDM_BLACKONWHITE:

wPrevItem = wPrevMode;

wPrevMode = wParam;

fStretchMode = BLACKONWHITE;

break;

case IDM_WHITEONBLACK:

wPrevItem = wPrevMode;

wPrevMode = wParam;

fStretchMode = WHITEONBLACK;

break;

case IDM_COLORONCOLOR:

wPrevItem = wPrevMode;

wPrevMode = wParam;

fStretchMode = COLORONCOLOR;

break;

}

CheckMenuItem(GetMenu(hWnd), wPrevItem, MF_UNCHECKED);

CheckMenuItem(GetMenu(hWnd), wParam, MF_CHECKED);

break;

Note that this new WM_COMMAND case handles the IDM_ABOUT case using a switch statement rather than an if statement.