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);
MemDCExercising = CreateCompatibleDC(hDC);
SelectObject(MemDCExercising, hbmp);
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?