Thread: How is the cursor drawn

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    41

    How is the cursor drawn

    Hi you all!

    This is a question about the basics of windows. Because I'm trying to make my own GUI (for games) I need to know how they work. It's going well so far, but I always make it harder and harder for myself and now I'm just a bit lost. So to help me back on track: How does windows handle mouse cursor drawing?
    And more in general: Does windows use a backbuffer or something?
    When I draw in windows, I draw to a DC, but what does that do? Has windows got a backbuffer with the whole desktop and windows in (video) memory? So it can erase the mouse cursor and redraw it whenever it moves.

    Well maybe you can explain this a bit, that way I have an idea how to do it myself...
    thanks

    Joren

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    I think its more like layers but I'm not 100% sure.

    One DC on top of another (z order). The cursor being a small one always on top.

    As to a back buffer, don't you use one?

    I do all my drawing to small DC's. Then when ready the smaller parts are drawn to a desktop sized DC. When I need for the screen to be redrawn this desktop sized DC is BltBit'ed to the screen's DC, another exact copy.
    A paint is now called to redraw just the area I need with InvalidateRect() using the screen's DC.
    These two buffers ensure that I can draw the smaller parts while I redraw the screen. The paint is also fast, one BltBit(), so no wait / freeze while redrawing.
    "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

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    I am almost sure that Windows uses buffer to store part of video memory under the cursor.

    As you might have noticed, no WM_PAINT messages are sent to your window procedure when you move mouse through the window client area, the occupied part of underlying picture renews itself from somewhere. Windows uses black&white pointers.

Popular pages Recent additions subscribe to a feed