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?
 
dr_funfrockConnect With a Mentor Commented:

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

0
 
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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

From novice to tech pro — start learning today.