Wm_paint

This is a discussion on Wm_paint within the Windows Programming forums, part of the Platform Specific Boards category; When the window is moved, resized, obstructed by another window, etc... windows will send your application a WM_PAINT message in ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    4

    Wm_paint

    When the window is moved, resized, obstructed by another window, etc... windows will send your application a WM_PAINT message in order for you to redraw the invalid region.

    case WM_PAINT:
    {
    // hdc = BeginPaint(hwnd, &paintstruct);
    // EndPaint(hwnd);
    } break;

    For a test, I commented the lines of code out to see what would happen. When I ran my simple program (It just displays a blank window.), I could still resize, move, etc.. and it still redrew the window. Why is this? Does windows do something I'm not aware of? Please help!

    Thanks,
    Codah

  2. #2
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    I'll give yah a hint: You don't een have to trap a WM_PAINT. Unless you keep windows from doing so somehow, it will always repaint the window.

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    4
    So you would only use WM_PAINT if you wanted to do some specific drawing tasks? In other words, windows will always do the basic drawing job?

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Windows will redraw ctrls and dlg's as long as they are not 'ownerdraw'. Other drawing must be handled. Anything in a HDC must be 'ownerdrawn'.

    In between beginpaint() and endpaint() you put the code you want executed when repainting.

    BeginPaint() only validates a region that has had paint called on it with InvalidateRect, UpdateWindow ect.

    EndPaint cleans up.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21