[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 618
  • Last Modified:

How do I display bitmaps on a CStatic during execution?

I have several bitmaps that I want to show up in my CStatic object, one at a time, depending on the state of the application. I am setting the bitmap up with the following code:

   CBitmap* theBitmap = new CBitmap();
   theBitmap->LoadBitmap(IDB_PICTURE1);
   m_myStatic.SetBitmap((HBITMAP)theBitmap);

This does *something*, you see a blank white box show up.  What am I doing wrong?  The picture doesn't show up.

Also, in the resource editor I load one bitmap onto the CStatic to start out with (and to be changed during execution).  When I test the dialog in resource editor it shows up, but not when I run the program.
0
appleby
Asked:
appleby
1 Solution
 
chensuCommented:
1. Make sure the static control has the SS_BITMAP style.
2. Don't delete the theBitmap object until the static control is destroyed.
3. Check the return value of LoadBitmap.
4. Try
m_myStatic.SetBitmap((HBITMAP)theBitmap);
m_myStatic.Invalidate();
m_myStatic.UpdateWindow();
0
 
applebyAuthor Commented:
Thank you!  I figured it was some kind of redrawing I was missing.  That did it.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now