Basic flickering/tearing problem

All questions regarding Windows programming, post here. API,COM, ActiveX, DirectX, OpenGL, MFC and so on...

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

Basic flickering/tearing problem

Postby Jaap » Tue May 04, 2010 12:23 am

Hi everybody,
I'm having problems drawing a window with child windows with a WM_PAINT handler without flickering.
I searched the forums a bit and I could see a lot of people with the same problems, but I couldn't really find an answer so here is my try:

Situation:

One window class registered:
style = CS_VREDRAW | CS_HREDRAW;
hbrBackground = (HBRUSH) COLOR_BACKGROUND+1;

One main window created:
dwExStyle = WS_EX_OVERLAPPEDWINDOW | WS_EX_COMPOSITED
dwStyle = WS_OVERLAPPEDWINDOW

And in this window, one child window is created:
dwExStyle = WS_EX_CLIENTEDGE
dwStyle = WS_CHILD

The child window is created in the WM_CREATE handler of the first one
WM_PAINT is handled by the child one (draws a static DIB on it)
All unhandled messages are handled by DefWindowProc()

The message-handling seems to be going fine, except for one thing:
Even though I'm using the WS_EX_COMPOSITED, the child window still flickers when I resize (gets a WM_PAINT due to CS_VREDRAW | CS_HREDRAW).
Even without handling the WM_PAINT in the child window, in which case the sunken border of the child window still flickers.

I must be doing something wrong, using the wrong styles or something, but I can't figure it out. Any suggestions? I'm trying to create a GUI where controls move around when the window is resized so afaik I can't turn off the CS_VREDRAW | CS_HREDRAW flag.

thanks in advance,

Jaap
Jaap
 
Posts: 104
Joined: Wed Nov 12, 2003 1:31 pm

Re: Basic flickering/tearing problem

Postby t i l e x » Fri Jul 09, 2010 7:30 pm

I haven't programmed in a while and it has been even longer since last time I used the Win32 API but I do think that you need to handle the WM_RESIZE message.

Code: Select all
case WM_RESIZE:
case WM_PAINT:
  /* do stuff  */
  break;
Or maybe use RedrawWindow() inside WM_RESIZE. Anyhow, I think the solution involves handling WM_RESIZE.

I figure after two months you've found the solution but it may help other posters.
User avatar
t i l e x
 
Posts: 3602
Joined: Wed Dec 03, 2003 3:59 pm
Location: Québec (Canada)


Return to Windows Programming

Who is online

Users browsing this forum: MSN [Bot], Yahoo [Bot] and 1 guest

cron