mfc >> bitmap object

by Wesley Lorrez » Sat, 29 Jan 2005 17:07:36 GMT

Hi

I use a bitmap object in a MFC dialog box to display an image. I have
assigned a variable m_picture_contr to the bitmap object and use it in a
button to assign a bitmap to it:

the code I use in the button:
CBitmap Bmp1;
Bmp1.LoadBitmap(IDB_RED);
m_picture_contr.SetBitmap(Bmp1);

When I move another window (or application) on top of the dialog box and
move it away again, the image is not there anymore, it is like wiped out by
the window I moved over. Can someone help me by informing me how to prevent
the bitmap from being wiped out by other applications/windows? Or what I do
wrong because it behaves like this? THX.

GreetingZ

Wesley






mfc >> bitmap object

by Jeff Partch [MVP] » Sat, 29 Jan 2005 21:34:57 GMT





by
prevent
do

Your CBitmap appears to be function local. If that's the case, then its dtor
will DeleteObject the HBITMAP it wraps as soon as the function exits. This
leaves your m_picture_control holding an invalid HBITMAP which it can no
longer repaint. Consider making your CBitmap a class member object as well.
--
Jeff Partch [VC++ MVP]





mfc >> bitmap object

by Wesley Lorrez » Sun, 30 Jan 2005 02:01:31 GMT

>> Consider making your CBitmap a class member object as well

THX !!

GreetingZ

Wes




Similar Threads

1. Bitmap Object Class - CSharp/C#

2. Bitmap object in a web image control

Hi all,

  I am new to .net programming.

 I have an application that need to show tiff image (page by page)in a web 
Image controlCan anyone advise me how I can do this.

If you can send some code snippet the it will be highly appeciated!.

Thakns and Regards

Rinu  

3. fixing Bitmap "object in use elsewhere" exception - CSharp/C#

4. Convert Bitmap object to indexed PNG

5. Rendering a Bitmap object as an image in WebPart - CSharp/C#

6. Graphics and Bitmap objects interop

I would like to have a hint to solve this problem:

I have a simple user control (myControl) and I'm writing a custom OnPaint 
event. I have the Graphics object passed through PaintEnventArgs. Now I would 
like to copy a region from the control 'canvas' to a Bitmap object to process 
it. How do I do this ?

Thanks in advance,

7. Get Bytes from Bitmap Object - CSharp/C#

8. Faster way of reading pixels from Bitmap object

I'm reading pixel values (RGB) from a bitmap object using function from 
system.drawing namespace & vb.net (.net framework 1.1)

But I would like to make it faster, so is there any another way of reading 
pixel values from bitmap objects? (some API or smthng)