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

Reply

Join Date: Sep 2004
Posts: 55
Reputation: apcxpc is an unknown quantity at this point 
Solved Threads: 0
apcxpc's Avatar
apcxpc apcxpc is offline Offline
Junior Poster in Training

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

 
0
  #1
Feb 27th, 2006
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...

  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).
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,343
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1460
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

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

 
0
  #2
Feb 27th, 2006
erase the window -- get current window RECT object then call FillRect() with the desired color.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC