BMP image displayed by VC

Source: Internet
Author: User
Tags bmp image
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 );

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.