Dialog Boxes, Menus, and Other Resources

A resource is binary data, such as a bitmap, an image, or a string, that you can add to application's executable file. Windows CE resources include cursors, icons, menus, dialog boxes, bitmaps, string-table entries, message-table entries, keyboard-accelerator tables, and user-defined data. The Windows CE-based platform you are targeting will determine which Windows resources are available for use.

Before using a resource, you must load it into memory. The FindResource function finds a resource in a module and returns a handle to the binary resource data. The LoadResource function uses the resource handle returned by FindResource to load the resource into memory. After you load a resource by using LoadResource, Windows CE automatically unloads and reloads the resource as memory conditions and application execution require. Thus, you need not explicitly unload a resource you no longer need.

You can use FindResource and LoadResource to find and load any type of resource, but it should use these functions only if it must access the binary resource data for subsequent function calls. To use a resource immediately, you should use one of the resource-specific functions described in the following table to find and load resources in one call.

Function Action
FormatMessage Loads and formats a message-table entry.
LoadAccelerators Loads an accelerator table.
LoadBitmap Loads a bitmap resource.
LoadCursor Loads a cursor resource.
LoadIcon Loads an icon resource.
LoadImage Loads an icon, cursor, or bitmap.
LoadMenu Loads a menu resource.
LoadString Loads a string-table entry.

Before terminating, an application should release the memory occupied by accelerator tables, bitmaps, cursors, icons, and menus by using one of the functions described in the following table.

Resource Release function
Accelerator table DestroyAcceleratorTable
Bitmap DeleteObject
Cursor DestroyCursor
Icon DestroyIcon
Menu DestroyMenu