943,520 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 8686
  • C RSS
Feb 27th, 2006
0

Drawing bitmap on window - how to clear window/HDC?

Expand Post »
Hi all

My program currently loads a bitmap (given a filename) and draws it to a window (win32 application).

The problem is that once a different bitmap is loaded and drawn to the window... if the new bitmap is smaller than the old bitmap, the edges of the old bitmap are still visible once the new bitmap is drawn.
I need a way to completely clear the window before drawing each new bitmap. ... How do I do this??




Here is where I paint the window...

Quote ...
  1. LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  2. {
  3. switch (message)
  4. {
  5. case WM_PAINT:
  6. {
  7. HDC hDC = GetDC(hwnd);
  8. if (cd->GetFilename() != NULL) cd ->DrawBits(hDC,0,0);
  9. ReleaseDC(hwnd, hDC);
  10. break;
  11. }
  12. //handle other messages
  13. }
  14. }
... where cd is the CDib*. (my bitmap class)

Each time the user loads a new bitmap to display, I call cd->LoadBitmapFile(filename).
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
apcxpc is offline Offline
55 posts
since Sep 2004
Feb 27th, 2006
0

Re: Drawing bitmap on window - how to clear window/HDC?

erase the window -- get current window RECT object then call FillRect() with the desired color.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,945 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Check data type input!!
Next Thread in C Forum Timeline: code optimization





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC