Click here to Skip to main content
Rate this: bad
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:
		case 'A': case 'a':
		hbmp =  LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP2));
		case 'B': case 'b':	
			hbmp =  LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP3));
			case 'C': case 'c':
			hbmp =  LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP4));
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);

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

Solution 2

It's completed on using InvalidateRect().

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 418
1 OriginalGriff 344
2 George Jonsson 233
3 Shemeemsha RA 138
4 Animesh Datta 130
0 OriginalGriff 6,179
1 Sergey Alexandrovich Kryukov 5,616
2 CPallini 4,770
3 George Jonsson 3,400
4 Gihan Liyanage 2,522

Advertise | Privacy | Mobile
Web03 | 2.8.140916.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