Thread: DCs and disappearing pixels

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    29

    Question DCs and disappearing pixels

    Well, I assume this is a pretty simple question, atleast for someone a bit more experienced than me

    I have a simple window, that allows you to draw in it using GDI functions, like an extremely simple stripped down version of MS Paint.

    Now, i'm fairly inexperienced with GDI operations at this point, and the problem is that when I minimize the window, or cover it with another window, anything I have drawn disappears.

    Now, I actually expected that, cause I have nothing so far to redraw the pixels once they have been invalidated.

    My question is, how do I save the information so that it can be redrawn next time the window needs updating? I'm just using SetPixelV to plot the pixels when the left mouse button is down, and I assume I need to preserve my window DC info somehow, but I don't know enough about the GDI yet to accomplish that

    Sorry for the long post, hope someone can clear this up for me.

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    If you want to store the values of mouse-clicks then perhaps an array of POINT structures might help. You can then iterate through the array to draw the POINTs when you need to.
    You may prefer to use one of the std template containers like a vector or list to store these points.

  3. #3
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    The best way to fix this, IMHO, is with an HDC in memory. Use CreateCompatibleDC() to create it, and draw to it as well as your regualr HDC to your window. Then on WM_PAINT just BitBlt() it to the screen.

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    29

    Smile

    Thanks both of you for replying. -KEN-'s idea seems to be what I needed

Popular pages Recent additions subscribe to a feed