Document directory
- BMP image displayed by VC
BMP image displayed by VC
Method 1:
1) modify the picture control attribute
2) directly associate with the image: Set the image attribute
3) change the type to bitmap.
Method 2: (pictureex online search)
1) Add the control variable as a pictureex object.
2) directly m_pic1.loadbitmap (idb_bitmap1 );
Example:
1. Associate the picture control object: m_stpicture
2. Add two BMP resources: idb_bitmap1 and idb_bitmap2.
3. Definition: hbitmapm_hbitmap;
4. Show the image at the beginning
Bool cshowbmp DLG: oninitdialog ()
{
Cdialog: oninitdialog ();
......
// Display the image
M_hbitmap = (hbitmap) LoadImage (AfxGetInstanceHandle (), makeintresource (idb_bitmap1), image_bitmap, 0, 0, lr_loadmap3dcolors );
M_stpicture.modifystyle (0xf, ss_bitmap );
M_stpicture.setbitmap (m_hbitmap );
Return true; // return true unless the control focus is set.
}
5. Switch Images
Void cshowbmp DLG: onbnclickedok ()
{
Static int nid = 0;
NID ++;
If (null! = M_hbitmap)
{
: Deleteobject (m_hbitmap );
M_hbitmap = NULL;
}
Int npicid = nid = NID % 2? Idb_bitmap2: idb_bitmap1;
M_hbitmap = (hbitmap) LoadImage (AfxGetInstanceHandle (), makeintresource (npicid), image_bitmap, 0, 0, lr_loadmap3dcolors );
M_stpicture.modifystyle (0xf, ss_bitmap );
M_stpicture.setbitmap (m_hbitmap );
}