When eve I repaint the window it flickers... Is there any way to stop the flickering??
Well, there are a couple of ways to help reduce the flicker (though I've never been able to get it to go completely away). The first is to tell Windows not to redraw the background: invoke InvalidateRgn,hWin,NULL,FALSE This also puts a WM_PAINT message on the queue. Another way is to keep track of areas that you updated and only redraw those parts of the screen for every WM_PAINT that's issued. The combination of these two techniques should limit the flicker to almost unnoticeable amounts, but as I've said, I've never gotten it to go away completely. Another option (if this is a possibility for you) is to use a timer and a bitmap. By making a bitmap and using it as a back buffer, you can cut back on GDI functions, then blit every few milliseconds or so, and draw to the back buffer. (For 60 FPS, you should blit every 16 milliseconds. It won't be exactly 60 FPS, it'll be more, but who cares?) This is a throwback from old, DOS based games and graphics, but it makes for smooth, fluid animation.
If the flicker occurs because you perform several GDI updates on the window, you can minimize it somewhat by calling LockWindowUpdate.
Another possible cause of window flicker is when the windows is composed of several elements, each of which is updated in the re-paint. As the window is partially updated, this goes to the display briefly before the complete repaint is finished. It looks horrible. It's simple to fix with double buffering. In the DOS days (whence this term orginated), one made a duplicate buffer for the screen display, did the update there, and then either coppied the working buffer to the display bufer, or just changed the working display buffer pointer (I actually never did this in DOS). To do this in windows, one creates a display contex compatable with the window to be updated. All drawing is done to this duplicate DC, when drawing is complete, this DC is blitted in it's entirity to the window, thus elimating a partial window update getting to the screen.
thanks alot :)