Creating Custom Check-mark Bitmaps
A custom check-mark bitmap must be the same size as the default check-mark bitmap. You can retrieve the default check-mark size of the bitmap by calling the GetSystemMetrics function. The low-order word of this function's return value specifies the width; the high-order word specifies the height.
You can use bitmap resources to provide check-mark bitmaps. However, because the required bitmap size varies depending on the display type, you may need to resize the bitmap at run time by using the StretchBlt function. Depending on the bitmap, the distortion caused by sizing could produce unacceptable results.
Instead of using a bitmap resource, you can create a bitmap at run time by using GDI functions.
To create a bitmap at run time
-
Use the CreateCompatibleDC function to create a device context compatible with the one used by the application's main window. The function's hdc parameter can specify either NULL or the return value from the GetDC function. CreateCompatibleDC returns the handle to the compatible device context.
-
Use the CreateCompatibleBitmap function to create a bitmap compatible with the application's main window. This function's nWidth and nHeight parameters set the size of the bitmap; they should specify the width and height information returned by the GetSystemMetrics function. You can also use the CreateBitmap function to create a monochrome bitmap.
-
Use the SelectObject function to select the bitmap into the compatible device context.
-
Use GDI drawing functions, such as Ellipse and LineTo, to draw an image into the bitmap, or use functions such as BitBlt and StretchBlt to copy an image into the bitmap.
For more information, see Bitmaps.