• C


How would I load a Bitmap with CImage that's not a resource.
If it had been a resource, I would do just fine.
But when I do something like

it just won't work.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Is this MFC & Win32?
dmatheoAuthor Commented:
MFC. I wanted to use the CImage component, in designing my dialog. I want to put a picture in that component. Usually during design time you can just attach the path and the name of the bitmap in the picture property of the CImage component. I needed to do it manually. And since the bmp that I'm going to display is a dynamic one, I can't use resource. So it has to be loaded from the disk.

Anyone knows how to deal with the problem?
I couldn't find a CImage class in the MFC documentation - do you mean CStatic?

If so...
1. Declare a CStatic member in your dialog class.
2. Attach it to the dialog control using DDX_Control(). (The class wizard will do 1 & 2 for you).
3. Use the LoadImage() Win32 API call to load the bitmap from disk.
4. Use CStatic::SetBitmap() to display the loaded image on the dialog control.
You need to load a DIB (Device Independent Bitmap). The DIBLOOK sample with VC++ illustrates this.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.