|
-
Jul 29th, 2001, 01:21 AM
#1
Thread Starter
Frenzied Member
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
-
Jul 29th, 2001, 01:32 AM
#2
PowerPoster
Can you please post the whole source code?
-
Jul 29th, 2001, 10:53 AM
#3
Thread Starter
Frenzied Member
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;
}
-
Jul 30th, 2001, 10:08 AM
#4
Frenzied Member
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.
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|