Click here to Skip to main content
Rate this: bad
good
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 20-Feb-13 0:49am
Comments
Jochen Arndt at 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
0 OriginalGriff 7,215
1 DamithSL 5,114
2 Maciej Los 4,866
3 Sergey Alexandrovich Kryukov 4,747
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2014
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