CBitmap::LoadBitmap()

I'm trying to load a bitmap into a CBitmap object and have no problem when I use the ID
    BmpOb.LoadBitmap(ID_MY_BMP)

but when I try to use the actual bitmap path
    BmpOb.LoadBitmap("c:\\mydir\\mybmp.bmp")

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

galkinCommented:
LoadBitmap works only with bitmap resource. Use LoadImage Win32 API function to load bitmap from a file
0
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

0
jtwine100697Commented:
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.
0
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.

MikeP090797Commented:
Why did you rejected galkins answer? The easiest way of loading bitmap is the LoadImage function
0
jtwine100697Commented:
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.

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

0
dr_funfrockCommented:

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

0

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.
Thanks!
0
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.