954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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

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...

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)                
    {
      case WM_PAINT:
        {
              HDC hDC = GetDC(hwnd);
              if (cd->GetFilename() != NULL) cd ->DrawBits(hDC,0,0);
              ReleaseDC(hwnd, hDC);
              break;
         }
        //handle other messages
       }
}

... where cd is the CDib*. (my bitmap class)

Each time the user loads a new bitmap to display, I call cd->LoadBitmapFile(filename).

apcxpc
Junior Poster in Training
55 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

erase the window -- get current window RECT object then call FillRect() with the desired color.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You