How redrawing works

This is a discussion on How redrawing works within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I've been wondering ever since I started programming - how does windows redraw windows? Like when you drag a ...

  1. #1
    Chad Johnson
    Join Date
    May 2004
    Posts
    154

    Question How redrawing works

    Hi,

    I've been wondering ever since I started programming - how does windows redraw windows? Like when you drag a window across the screen, how does it redraw the stuff that's 'behind' that window?

  2. #2
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    look in to wm_paint and the message que

    edit

    also look up dib.

  3. #3
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Essentially, the "behind" windows are notified by Windows that some portion of it has been invalidated (the portion that has become "uncovered" as a result of the foreground window moving to reveal it), then the "behind" window repaints itself so it doesn't appear blank where the foreground window moved from. A perfect example of this is when an app stops responding and you drag other apps across it; it is hanging and, thus, no longer responding to messages and the dragged over parts just turn white.

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    How the screen 'looks' is contained in a BMP.

    A Device Context (DC) contains the BMP and the other current Graphical Device Interface objects (GDI) used. (pen, brush and font ect)

    Your app (or the OS) sends a paint msg to the window that needs repainting. It does this by 'invaldating' the area (usually a rectangle).

    In the paint handler (WM_PAINT) you call BeginPaint().
    BeginPaint() gets the section of the DC for the current window that is invalid (needs painting) and redaws it based on the window class (background colour, font ect) or your code (image you have stored in a seperate DC). The BeginPaint() sets the area to valid again.

    EndPaint() cleans up the GDI reources.
    "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

  5. #5
    Chad Johnson
    Join Date
    May 2004
    Posts
    154
    hmmm...that's pretty interesting how they do all that. I'll look into those links you posted, Lucky.

    What kind of data structures in memory are the graphics for windows stored in?

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    >>What kind of data structures in memory are the graphics for windows stored in?

    Device Contexts
    "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

Similar Threads

  1. Can anybody show me why this works??
    By tzuch in forum C Programming
    Replies: 2
    Last Post: 03-29-2008, 10:03 AM
  2. explanation of how this works
    By c++.prog.newbie in forum Linux Programming
    Replies: 3
    Last Post: 09-27-2004, 06:59 PM
  3. Works in MSVC++ 6.0 but not in Dev-C++
    By smitsky in forum C++ Programming
    Replies: 1
    Last Post: 05-30-2004, 09:07 PM
  4. fprintf works in one function but not in the other.
    By smegly in forum C Programming
    Replies: 11
    Last Post: 05-25-2004, 04:30 PM

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