Creating Icons, Bitmaps, Images, and Strings

An icon is an image that used to identify an application, file, or other object. It consists of a bit image combined with a mask. An application icon always appears on the taskbar while the application is running, and it can be used to recover the application main window when another window has the foreground. The icon can also be used to identify the application in the Windows CE Explorer. Every application should register both 16 by 16 pixel and 32 by 32 pixel icons for its main executable file and the types of files it stores in the file system.

A bitmap is a graphics image that you can include in an application. Unlike icons, which have a fixed size, you determine the bitmap size. Both icons and bitmaps must be defined in a resource file.

    To create an icon

  1. Draw the icon by using a graphics application.
  2. Include the icon as a resource in the application resource-definition file.
  3. Call the WM_SETICON message to associate an icon with a window class.

    Icons are associated with window classes rather than with individual windows.

  4. Call the WM_GETICON message to retrieve the handle of the icon that is associated with a window class.

Note Windows CE does not support any of the standard predefined icons (IDI_*) that Windows-based desktop platforms support.

    To create a bitmap

  1. Draw the bitmap by using a graphics application.
  2. Include the bitmap as a resource in the application resource-definition file.
  3. Call the LoadBitmap function to initialize the bitmap.

    The bitmap you create with this function will be read-only because Windows CE does not copy the bitmap into RAM as Windows-based desktop platforms do.

  4. Call the SelectObject function to select the bitmap into a device context. This enables you to display the bitmap.

    When you select the bitmap into a device context, you cannot modify the device context—for example, by drawing text into it—because that would require the ability to write to the bitmap.

Images and strings are created similarly to icons and bitmaps. Both are resources that must be defined in a resource file. The following code example shows how to define a resource for an icon, bitmap, cursor, and string.

#include "windows.h"

#define IDB_BITMAP                      101
#define IDC_CURSOR                      102
#define IDI_CEPADICON                   103

IDB_CEPADBITMAP     BITMAP  DISCARDABLE     "CePad.bmp"
IDC_CEPADCURSOR     CURSOR  DISCARDABLE     "CePad.cur"
IDI_CEPADICON       ICON    DISCARDABLE     "CePad.ico"

STRINGTABLE DISCARDABLE 
BEGIN
  1                 "CePad"
  2                 "CePad Application"
END

When adding an image or string to an application, call the LoadImage function to load an image and call the LoadString function to load a string. Windows CE does not support stretching and shrinking of images or any loading options other than LR_DEFAULTCOLOR. Windows CE supports only Unicode strings.