MFC CBitmap LoadBitmap()
-
Hi all, Bit of a problem with CBitmap's LoadBitmap() function. If I make a bitmap a resource and do BitmapObj.LoadBitmap(IDB_MYBITMAP); The image is loaded fine, but if I do BitmapObj.LoadBitmap("MyBitmap.bmp"); it returns 0 (failed). I've tried moving the location of the file around the local directory (debug, res, etc.) but no luck. What do I need to do? Obseve everything, remember more...
-
Hi all, Bit of a problem with CBitmap's LoadBitmap() function. If I make a bitmap a resource and do BitmapObj.LoadBitmap(IDB_MYBITMAP); The image is loaded fine, but if I do BitmapObj.LoadBitmap("MyBitmap.bmp"); it returns 0 (failed). I've tried moving the location of the file around the local directory (debug, res, etc.) but no luck. What do I need to do? Obseve everything, remember more...
You can't load a bitmap file like that. To load a bitmap image from a file, use
LoadImage()
:HBITMAP hbm = (HBITMAP)LoadImage(NULL, "MyBitmap.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
Hope this helps, Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact" -
You can't load a bitmap file like that. To load a bitmap image from a file, use
LoadImage()
:HBITMAP hbm = (HBITMAP)LoadImage(NULL, "MyBitmap.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
Hope this helps, Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact" -
Okay, but there is a function LoadBitmap() that takes an LPCTSTR string of the name of the bitmap. How does one use it? Obseve everything, remember more...
It loads a bitmap from a resource. If you look at the MFC source code, you'll find that the one that takes a UINT actually calls the one that takes a LPCTSTR to do the work. All resources are loaded via strings. The UINTs have to be coerced into looking like strings so that Windows can load them. Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"