11.6 Sample Application: Bitmap

This sample shows how to incorporate a variety of bitmap operations in an application. In particular, it shows how to do the following:

Load and display a monochrome bitmap

Create and display a color bitmap

Stretch and compress a bitmap by using the mouse

Set the stretching mode

Create and use a pattern brush

Use a pattern brush for the window background

In this application, the user specifies (by using the mouse) where and how the bitmap will be displayed. If the user drags the mouse while holding down the left button, and then releases that button, the application uses the StretchBlt function to fill the selected rectangle with the current bitmap. If the user clicks the right button, the application uses the BitBlt function to display the bitmap.

To create the Bitmap application, make the following modifications to the Generic application:

1.Add constant definitions and a function declaration to the header file.

2.Add two monochrome bitmaps, created by using Image Editor, to the resource-definition file.

3.Add Bitmap, Pattern, and Mode menus to the resource-definition file.

4.Add global and local variables.

5.Add a WM_CREATE case to the window procedure to create bitmaps and add bitmaps to the menus.

6.Modify the WM_DESTROY case in the window procedure to delete bitmaps.

7.Add WM_LBUTTONUP, WM_MOUSEMOVE, and WM_LBUTTONDOWN cases to the window procedure to create a selection rectangle and display bitmaps.

8.Add a WM_RBUTTONUP case to the window procedure to display bitmaps.

9.Add a WM_ERASEBKGND case to the window procedure to erase the client area.

10.Modify the WM_COMMAND case to support the menus.

11.Modify the link command line in the makefile to include the SELECT.LIB library file.

12.Compile and link the application.