Results 1 to 4 of 4

Thread: graphic dissapeared

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800

    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

  2. #2
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Can you please post the whole source code?
    Baaaaaaaaah

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    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;
    }

  4. #4
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    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
  •  



Click Here to Expand Forum to Full Width