Click here to Skip to main content
15,888,062 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

Please excuse the code below. I'm just hacking at the moment.
I have a question, essentially the below code displays 3 images.
The 1st image displays the background, and the remaining 2 smaller images are simple logos. It renders fine, however when I drag the dialog box. It fails to re-paint the background?

Could somebody be so kind and enlighten me on this problem and how to resolve it. My memory is indeed bad.

Thanks,
Garyc

C++
 void CtesterDlg::OnPaint()
   {
   	CPaintDC dc( this ); // Device context for painting
         CBitmap bmp, *poldbmp;
         CDC memdc;
        	  // Load the bitmap resource
		 bmp.LoadBitmap(IDB_BITMAP1);
         // Create a compatible memory DC
         memdc.CreateCompatibleDC( &dc );
         // Select the bitmap into the DC
         poldbmp = memdc.SelectObject( &bmp );
         // Copy (BitBlt) bitmap from memory DC to screen DC
         dc.BitBlt(0, 0,2000,4000, &memdc, 0, 0, SRCCOPY );   

         // Copy (BitBlt) bitmap from memory DC to screen DC
    
       
         memdc.SelectObject( poldbmp );
		   // Load the bitmap resource
		 bmp.LoadBitmap(IDB_BITMAP2);
         // Create a compatible memory DC
         memdc.CreateCompatibleDC( &dc );
         // Select the bitmap into the DC
         poldbmp = memdc.SelectObject( &bmp );
         // Copy (BitBlt) bitmap from memory DC to screen DC
         dc.BitBlt(20,320,400,400, &memdc, 0, 0, SRCCOPY );
		  memdc.SelectObject( poldbmp );
		   // Load the bitmap resource
		 bmp.LoadBitmap(IDB_BITMAP3);
         // Create a compatible memory DC
         memdc.CreateCompatibleDC( &dc );
         // Select the bitmap into the DC
         poldbmp = memdc.SelectObject( &bmp );
         // Copy (BitBlt) bitmap from memory DC to screen DC
         dc.BitBlt(550,320,450,6000, &memdc, 0, 0, SRCCOPY );
}
Posted
Updated 2-Mar-10 22:49pm
v2

:)

Enlightenment 1: Try memdc.DeleteDC() after its each usage
Enlightenment 0: We should try to analyze every assertion/exception by debugging (line, stack, vars, regs...)
 
Share this answer
 
try refreshing the dialog box.

CDialog::Invalidate(1);
CDialog::UpdateWindow();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900