From: "Steve Pick" <[EMAIL PROTECTED]>
I've recently been looking into the flickering resize in win32::gui. The
most compatible solution to this I've found is extremely (and very
annoyingly) simple. Just add the style WS_CLIPCHILDREN to your window or
dialog box.

Steve,

I've just tried this and it works...Well, sort of:) On XP, any window behind the window being resized tear as they are redrawn. Also, for some reason there seems to be a delay in some of the events to any window with WS_CLIPCHILDREN set (!?). In my case, it means I can't use WS_CLIPCHILDREN which is a shame since the application looks and feels so *much* better without the flicker.

Doing a little searching I came across this page http://www.catch22.org.uk/tuts/flicker.asp

===========
WM_ERASEBKGND
The prime suspect is usually the WM_ERASEBKGND message. This message is sent to a window when it's background needs to be erased. This happens because windows are usually painted using a 2-stage process:

WM_ERASEBKGND: Clear the background
WM_PAINT: Draw the contents on top

....

Right then, how do we avoid erasing the background of a window? There are two methods.

Set the window's background brush to NULL. (Set the hbrBackground member of the WNDCLASS structure to zero when you register the window class).
Return non-zero in the WM_ERASEBKGND message handler.
Any one of these will steps will prevent the WM_ERASEBKGND message from clearing the window. The last option is usually easiest to implement:

case WM_ERASEBKGND:
   return 1;
It is also possible to prevent WM_ERASEBKGND when you invalidate and update a window. The InvalidateRect API call's last parameter specifies whether or not a portion of a window is to have it's background erased when it is next redrawn. Specifying FALSE for this paramter prevents WM_ERASEBKGND from being sent when the window is redrawn.

InvalidateRect(hwnd, &rect, FALSE);

============

I've no idea how to write a message handler for WM_ERASEBKGND - any ideas? I've played with InvalidateRect in the past but didn't get anywhere fast.

I tried to implement double-buffering in GUI.xs (I was working with 0.0.558
at the time) but frankly I failed.

Have a look at some of the code in this page:

http://www.codeproject.com/gdi/flickerfree.asp

"This article presents a class called CMemDC that encapsulates most of the issues associated with writing to off-screen buffers. Adding CMemDC to an existing application or MFC Active X control is nearly trivial.

Modifying an MFC Application to use CMemDC
Add the file memdc.h in your project.
Add the line #include "memdc.h" to stdafx.h.
Add a windows message handler for WM_ERASEBKGND. "

Would it be hard to incorporate it into GUI.xs somehow? The code is opensource.

Cheers,

jez.

_________________________________________________________________
Find a cheaper internet access deal - choose one to suit you. http://www.msn.co.uk/internetaccess


Reply via email to