In all the 'flicker free' tutorials the memory device context is created every time for drawing to the backbuffer bitmap. Can i create it once on window creation and select new bitmaps to it on the WM_SIZE message and BitBlt to the window device context on each WM_PAINT message? Or should i recreate compatible DC, every time i need to create new bitmap or just draw to it?
Posted on 2004-03-24 03:42:58 by Vaxon
You need to recreate your compatible DC every time yes.
Posted on 2004-03-24 09:42:04 by bj1500
You can keep DC's around, but...

1) Don't create too many, if you want your application to run well on Windows 9x. 9x is an utter piece of shit with a lot of limitations because of it's win16 legacy. Keeping a couple around permanently (like, one for your main window, one for your backbuffer, and one for SelectObject+BitBlt) shouldn't be a problem. Having one permanent DC for every bitmap in your app would be bad.

2) Be very sure to clean up any DC's (and in generall, all GDI objects), this includes selecting old-values back into the DC when you are done with your own objects. Win9x is very picky about GDI leaks, and will not clean up GDI objects on program crash (can't remember if it even cleans up leaked GDI objects on clean app termination). GDI bugs will rather quickly lead to BSODs on 9x.

You could also look into the CS_OWNDC class style.
Posted on 2004-03-24 09:53:06 by f0dder