Solved

CBitmap::LoadBitmap()

Posted on 1998-02-19
9
1,536 Views
Last Modified: 2013-11-20
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?
0
Comment
Question by:Grailman
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 7

Expert Comment

by:galkin
ID: 1316391
LoadBitmap works only with bitmap resource. Use LoadImage Win32 API function to load bitmap from a file
0
 
LVL 1

Author Comment

by:Grailman
ID: 1316392
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
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1316393
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 8

Expert Comment

by:MikeP090797
ID: 1316394
Why did you rejected galkins answer? The easiest way of loading bitmap is the LoadImage function
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1316395
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
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1316396
About the first problem, you can use CBitmap::FromHandle() to get it into CBitmap.
0
 
LVL 2

Expert Comment

by:anichini
ID: 1316397
I believe LR_LOADFROMFILE is supported on NT 4.0+
it is not supported on any older versions, though.

0
 

Accepted Solution

by:
dr_funfrock earned 50 total points
ID: 1316398

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

0
 
LVL 1

Author Comment

by:Grailman
ID: 1316399
Detach() seems to do it ok. Guess just I wasn't paying attention.
Thanks!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Turn a spreadsheet into a vba executable. 2 87
isEverywhere  challenge 19 76
twoTwo  challenge 35 103
Is there a simple front-end menu system. 9 89
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question