Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm writing a program to display multiple images on character select:
my code is on WM_CHAR:

C++
case WM_CHAR:
		{
		
		switch((char)wParam)
		{
				
		case 'A': case 'a':
			
		hbmp =  LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP2));

		break;
		case 'B': case 'b':	
	
			hbmp =  LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP3));
			
			break;
			case 'C': case 'c':
			hbmp =  LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP4));
			
			break;
		 default:
            break;
		
		}
		}
		break;


and on paint event:

C++
case WM_PAINT:

		{
 hDC = GetDC(picBoxDisp);
  
 	    /* Create a memory device compatible with the above DC variable*/
	    MemDCExercising = CreateCompatibleDC(hDC);
             /* Select the new bitmap*/
             SelectObject(MemDCExercising, hbmp);
	    /* Copy the bits from the memory DC into the current dc*/
	    BitBlt(hDC, 0, 0, 200, 200, MemDCExercising, 0, 0, SRCCOPY);
DeleteObject(hbmp);			
    DeleteDC(MemDCExercising);
	
	SendMessage(picBoxDisp,BM_SETIMAGE,IMAGE_BITMAP,(LPARAM)hbmp);

Images are being shown but second image is over first and third is over second.
How to erase the previous image?
Posted
Comments
Jochen Arndt 20-Feb-13 8:46am    
If your window handles the WM_ERASEBKGND message, just send this message. Otherwise use FillRect() passing the client rect of your window and a standard system color or a solid brush.

Please do not post the same question in multiple forums. I already responded to this at http://www.codeproject.com/Messages/4500317/On-displaying-two-images-second-image-overlapps-fi.aspx[^].
 
Share this answer
 
It's completed on using InvalidateRect().
 
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