-
graphic dissapeared
I have this code in my WM_PAINT method
Code:
hDC = BeginPaint(hWnd, &ps) ;
GetClientRect(hWnd, &rect) ;
hBitmap = LoadBitmap(ghInst, MAKEINTRESOURCE(IDB_BITMAP1));
GetObject(hBitmap, sizeof(BITMAP), &bm);
hMemDC = CreateCompatibleDC(hDC);
SelectObject(hMemDC, hBitmap);
BitBlt(hDC, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
DeleteDC(hMemDC);
EndPaint(hWnd, &ps);
DeleteObject(hBitmap);
If I have no controls on the form it shows up, otherwise it's not there......whats wrong :confused:
-
Can you please post the whole source code?
-
for the whole program???????? its big......
I'll just put what has to do with the pic
Code:
HINSTANCE ghInst; //used for picture
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
HDC hDC, hMemDC; // }
HBITMAP hBitmap; // }
BITMAP bm; // } graphics stuff
PAINTSTRUCT ps; // }
RECT rect; // }
switch(uMsg) {
case WM_CLOSE:
DestroyWindow(ghWnd_Main); // Destroy the main window
return 0;
case WM_DESTROY:
PostQuitMessage(0); // Quit the application
return 0;
case WM_PAINT: //updates the pic everytime needed
hDC = BeginPaint(hWnd, &ps) ;
GetClientRect(hWnd, &rect) ;
hBitmap = LoadBitmap(ghInst, MAKEINTRESOURCE(IDB_BITMAP1));
GetObject(hBitmap, sizeof(BITMAP), &bm);
hMemDC = CreateCompatibleDC(hDC);
SelectObject(hMemDC, hBitmap);
BitBlt(hDC, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
DeleteDC(hMemDC);
EndPaint(hWnd, &ps);
DeleteObject(hBitmap);
return 0;
}
-
Try moving your HBITMAP to be global, and then move the DeleteObject to some where where it is not destroyed on the paint like WM_CLOSE.
If this doesn't work, please .zip you whole project and post.