Loading a map, you can use LoadImage:
HANDLE LoadImage (HINSTANCE hinst, LPCTSTR lpszName, UINT uType, int cxDesired, int CyDesired, UINT fuLoad);
LoadImage can be used to load bitmaps, icons and cursors
When loading a predetermined map can be loaded into memory the size of the graph:
cxDesired: Specifies the width of the icon or cursor, in pixels. If this parameter is zero and the parameter value LR_DEFAULTSIZE fuLoad is not used, the function uses the current resource width.
cyDesired: Specifies the height of the icon or cursor, in pixels. If this parameter is zero and the parameter value LR_DEFAULTSIZE fuLoad is not used, the function uses the current resource level.
LoadImage return value is the handle of related resources. Because the load is a bitmap so the handle is returned HBITMAP type (need to cast).
Extending understand HBITMAP / CBitmap / BITMAP:
HBITMAP is bitmap pointer,
msdn in the case: Handle to a bitmap.typedef HANDLE HBITMAP;
CBitmap is encapsulated bitmap mfc classes;
Encapsulates (include) a Windows graphics device interface (GDI) bitmap and provides member functions to manipulate (operating) the bitmap.
BITMAP is a structure that encapsulates some of the bitmap information. It defines the height, width, color, format and bit-valued logic bitmaps.
MSDN in the case: This structure defines the type, width, height, color format, and bit values of a bitmap.
The relationship between the three conversion:
// Here is the link between the three:
bitmap.Attach (hBitmap); // get the HBITMAP associated CBitmap
bitmap.GetBitmap (& bm); // get BITMAP linked by CBitmap
hBitmap = (HBITMAP) bitmap.GetSafeHandle (); // get the HBITMAP associated CBitmap
BITMAP structure has the following form:
typedef struct tagBITMAP
int bmWidth; // Wide
int bmHeight; // High
By extending understanding Attach / Detach:
is to attach a C ++ object is associated with a WINDOWS object until you put the association with detach removed.
If you attach no later detach, the C ++ object is destroyed when the object along WINDOWS finished together.
attach later, HWND C ++ object pointer and WINDOWS objects have a mapping which acts you directly to a C ++ object Create a WINDOWS object, such as CEdit edit; edit.create (...)
And this map is permanent, know this until the object is finished.
If a similar GetDlgItem function can return a pointer and can be cast. GetDlgItem will find the mapping table.
There are two kinds of mapping table, is a permanent, one is temporary.
WINDOWS object directly in C ++ objects created by attach or object mappings are placed in a permanent table, or to create a map in a temporary table.
So GetDlgItem do not recommend you save the returned pointer, because it's hard to keep your WINDOWS objects associated with the C ++ object is placed in a permanent table.
If the mapping is in a temporary table, then the idle time will be automatically deleted.
With attcah solely for the convenience of using MFC class member functions to manipulate WINDOWS object.