|
I'm writing a program to display multiple images on character select:
my code is on
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;
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 displayed correctly but second image overlapps first...
|
|
|
|
|
DeleteObject(hbmp);
DeleteDC(MemDCExercising);
SendMessage(picBoxDisp,BM_SETIMAGE,IMAGE_BITMAP,(LPARAM)hbmp);
You are sending a handle to a deleted object in the last line of this code. What does the recipient of this message expect to do with it?
|
|
|
|
|
That doesn't explain the images overlapping. The overlapping might be a result of none identical size of the images.
|
|
|
|