How do I use a double buffer in this case?

Let's say I have three controls A, B, C. They all inherit from CDialog, A is the main dialog, A contains B, and B contains C. and every time I use the mouse, mouse C, B and C will move together.

This image: http://img507.imageshack.us/img507/7039/31709956.jpg

We know this will cause B and C to be redrawn. and this may cause flickering.

And my question is, isn't there a method to double buffering these two dialogs B and C?

I know XP and Vista have a WS_EX_COMPOSITED attribute that will help, but I don't want to use that.

someone might suggest me to use memDC, but my problem is how can I combine the activities in B ondraw and C ondraw into a buffer?

Hope someone knows what I said.

Thanks in advance!

+2


source to share


5 answers


which hints flicker a lot is to overload the erasebackground method. This method fills the entire background with a solid color. Paint than paint all the objects on it. By removing the erasebackground, the paint will simply paint over the material that already exists, thereby removing the flicker.



+2


source


CS_PARENTDC will help.



+1


source


I've never encountered double-buffered Windows calls, but one day I came across a discussion about it on the Microsoft forum: http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/789a4116-d3b2-488e- 801a-3f7bc1e4d33a / Maybe this might be useful for you.

+1


source


Assuming B and C are children of A (the usual case for dialogs), A should be styled WS_CLIPCHILDREN

. If B and C are siblings instead of A, set bit A WS_CLIPSIBLINGS

.

0


source


Take one MemDC for main dialog A and combined MemDC for B and C. Now when u drag and drop C, you have to combine these 2 MemDCs depending on the current position using the BitBlt function, and then finally you need to bitbtt the combined memDC on the actual DC dialogue.

Along with that, you have to override the onerasebackground method so the flicker won't be there.

0


source







All Articles