Share via


Creating Icons, Bitmaps, Images, and Strings (Windows CE 5.0)

Send Feedback

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 operating systems 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 — or example, by drawing text into it — because that would require the ability to write to the bitmap.

The following code example shows how to load a bitmap and display it.

HBITMAP hbm = LoadBitmap(hInst,MAKEINTRESOURCE(IDB_BITMAP1));

// Clear the window.
InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd);

HDC hdc = GetDC(hWnd);
HDC hdcTemp = CreateCompatibleDC(hdc);
SelectObject(hdcTemp, hbm);

// Get the size of the bitmap.
BITMAP bm;
GetObject(hbm, sizeof(BITMAP), &bm );

BitBlt(hdc, 50, 50, bm.bmWidth + 50, bm.bmHeight + 50, hdcTemp, 0, 0, SRCCOPY);

ReleaseDC(hWnd,hdc);

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.

See Also

Using Resources | GWES Application Development

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.