I'm trying to load a bitmap into a CBitmap object and have no problem when I use the ID

but when I try to use the actual bitmap path

it won't load. How do I go about loading a bmp using a string?
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.

LoadBitmap works only with bitmap resource. Use LoadImage Win32 API function to load bitmap from a file
GrailmanAuthor Commented:
I found a function on the web to read in a BMP and load it to my CBitmap object that works, but when I try to delete it in order to load another BMP I always get assertion errors???

BmpOb.DeleteObject()   // causes assertion errors

You are going to need to tell WHAT assertion is occuring...  Is it asserting because the class' internal object handle is NULL?

Also...  Check out the source code to the function that loads the BMP into the CBitmap object, and check if it is messing around with the object handle.

-=- James.
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Why did you rejected galkins answer? The easiest way of loading bitmap is the LoadImage function
Two possible reasons:

   o He has a function to load into a CBitmap
   o The LR_LOADFROMFILE flag to LoadImage(...) is not supported under NT (according to the Docs...).

   Just a thought...

-=- James.

About the first problem, you can use CBitmap::FromHandle() to get it into CBitmap.
I believe LR_LOADFROMFILE is supported on NT 4.0+
it is not supported on any older versions, though.


 Try CBitmap::Attach( << Bitmap Handle From LoadImage() >> )
   and CBitmap::Detach


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
GrailmanAuthor Commented:
Detach() seems to do it ok. Guess just I wasn't paying attention.
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
System Programming

From novice to tech pro — start learning today.