[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 361
  • Last Modified:

CImage

How would I load a Bitmap with CImage that's not a resource.
If it had been a resource, I would do just fine.
But when I do something like

m_Image.LoadBitmap('C:\\blablabla\\blablabla');
it just won't work.
0
dmatheo
Asked:
dmatheo
  • 2
1 Solution
 
abancroftCommented:
Is this MFC & Win32?
0
 
dmatheoAuthor Commented:
MFC. I wanted to use the CImage component, in designing my dialog. I want to put a picture in that component. Usually during design time you can just attach the path and the name of the bitmap in the picture property of the CImage component. I needed to do it manually. And since the bmp that I'm going to display is a dynamic one, I can't use resource. So it has to be loaded from the disk.

Anyone knows how to deal with the problem?
0
 
abancroftCommented:
I couldn't find a CImage class in the MFC documentation - do you mean CStatic?

If so...
1. Declare a CStatic member in your dialog class.
2. Attach it to the dialog control using DDX_Control(). (The class wizard will do 1 & 2 for you).
3. Use the LoadImage() Win32 API call to load the bitmap from disk.
4. Use CStatic::SetBitmap() to display the loaded image on the dialog control.
0
 
andymurdCommented:
You need to load a DIB (Device Independent Bitmap). The DIBLOOK sample with VC++ illustrates this.
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now