How do i prevent flicker when i resize my window?
Posted on 2001-07-25 15:58:04 by ChimpFace9000
Afternoon, ChimpFace9k.

How do i prevent flicker when i resize my window?

This depends on your code.;)

Are you updating the windows' info during a 'WM_SIZE' or 'WM_SIZING' message? There are many options available, depending on what your proggy does.

i.e. for scrolling up/down in a text proggy, I just grab a piccy of the client contents, paste this at the correct position (down/up), and update the line which has appeared.

Some proggys draw everything to an off-screen 'virtual' window, then grab a piccy of it and paste the entire contents to the 'physical' window.

To make a short answer even longer..;)
Just make sure you process the 'WM_SIZE' , 'WM_SIZING' , or 'WM_MOVING' messages so that the contents of the window are not redrawn while the window is resizing.

As I said before, this is entirely dependant on what your progy is meant to do and what info is being displayed, so the above advice could be completely useless to you.:grin:

Posted on 2001-07-25 17:13:12 by Scronty
Its a window with an edit control, and when i size the window it makes the edit control take the whole window. I use MoveWindow in the WM_SIZE message to do this.
Posted on 2001-07-25 17:50:38 by ChimpFace9000
When I first create the window, I set it to NULL.
That always works for me. But its only good if your edit control is taking up the entire viewing area on your window.

mov wndclass.hbrBackground, NULL
Posted on 2001-07-25 20:57:07 by dl?

there is and file on Iczelion's site a tutorial about flicker/non flicker

it reduces flicker to zero using a backbuffer
Posted on 2001-07-25 21:40:51 by BogdanOntanu

I just went through this for a listview control. The ESF tut by Chris Hobbs is probably the most elegant solution, but I did find a simple solution at

I know, I know, but ignore that it's C ;)

"How do I resize child window controls without flicker?

Flicker happens when Windows processes WM_PAINT messages.
Before dispatching WM_PAINT, Windows sends the
WM_ERASEBKGND message. The default processing for
WM_ERASEBKGND is to fill the client area with the window's
background color and then to draw the child windows. This
causes all child windows and controls to momentarily disappear
- hence flicker.

One way to reduce flicker is to trap the WM_ERASEBKGND
message and NOT fill the client rectangle with the background
color. This is done with the following code:

return 1;

Returning any non-zero value from the windows procedure during
the processing of WM_ERASEBKGND will prevent windows from
erasing the background. You can now resize the child windows.
After the child windows are resized you can fill the remaining
areas of the client window with the background color."

So I just put this in my WndProc messaging loop:

mov eax,1

The text itself seems to flicker a bit on resizing, but the main listview window looks fine.

Posted on 2001-07-25 23:05:54 by Unregistered
That works great, thanks!
Posted on 2001-07-26 00:17:05 by ChimpFace9000