Click here to Skip to main content
12,881,797 members (30,834 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VC6 VC7 C++ C++/CLI C
I'm writing a program to display multiple images on character select:
my code is on WM_CHAR:

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:

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 19-Feb-13 23:49pm
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.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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[^].
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

It's completed on using InvalidateRect().
  Permalink  

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

    Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.170422.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100