Log in

View Full Version : Displaying a bitmap in a view


Dhustone
01-24-2004, 12:17 PM
Here's the problem.
I've created a eVC app as an SDI and placed a splitter window in the mainframe window. That builds fine.
With one of the splitter views I want to load a 256 colour bitmap stored in the app itself. I've tried loading it from an ID number and a string but it refuses to display.
I've tried to load it from the view classes OnDraw() and OnInitialUpdate() but to no avail.
The bitmap member in the function accepts the ID and the SelectObject() takes the variable and then... nothing.
Its getting to the stage where I might have some stickers made and slap one on the screen each time I fire up the app!

I don't want to use imgdecmp or anything like that cos its too heavy duty and instructions are thin on the ground.

Help?

rhmorrison
01-27-2004, 11:48 AM
Maybe if you posted a snippet of your code...

In any case, once you have a bitmap loaded you need to draw the bitmap in response to the paint message OR you are using an image control.

There are articles describing how to use imgdecmp but you don't need this if you have the bitmap defined as a resource in your program.

You also might want to take a look at this article (http://www.codeproject.com/ce/picview.asp?print=true).

Dhustone
01-30-2004, 10:31 AM
My main bug-bear is how to access the resource image from my document class. After studying alot of different methods of drawing, I feel my OnDraw() is about there. It is only waiting for the HBITMAP from the doc class.
In my doc class I have placed a HBITMAP member but don't know which MFC functions or macros to include in my GetBitmap() to fetch the resource. The resource is included in the app.

Any ideas?

rhmorrison
01-30-2004, 01:27 PM
Then take a look at this example (http://www.codeproject.com/bitmap/membm.asp?print=true).

Dhustone
02-01-2004, 10:42 PM
Thanks Bob!
Much appreciated. Think I'll spend more time looking around CodeProject as it seems to be a goldmine.

Again, cheers!