The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: xroot on August 27, 2008, 04:36:41 PM

Title: Flicker
Post by: xroot on August 27, 2008, 04:36:41 PM
Hi,
Can someone help me stop the flicker on xhairs.
I tried to use Chris Hobbs ESF (Eliminating Screen Flicker).
I tried to use the message system with WM_ERASEBKGND and WM_PAINT.
I have tried combinations of the "flags" parm on the RedrawWindow api.
There is a simple solution but can't find it.
Thanks for any help.

[attachment deleted by admin]
Title: Re: Flicker
Post by: hutch-- on August 27, 2008, 06:01:05 PM
xroot,

Without having looked at your example, flicker is generally the interaction of two or more screen refreshes on the same area of the screen, generally the client area of a window. Thre are a couple of approaches as long as you undersand what is happening. If the main window is covered by another window, an edit control for example, set the main window background brush to NULL or HOLOW_BRUSH and you reduce one source of flickering as you remove one repaint for the windows client area.

If your window does not need it, do not set the CS_VREDRAW ans CS_HREDRAW style to the WNDCLASSEX and this reduces the repaint count by a lot.

If you are drawing text on the client area and getting flicker from some interaction, create a back buffer, do all of the messy flickery stuff there and BitBlt the result to the screen's client area.
Title: Re: Flicker
Post by: xroot on August 27, 2008, 06:42:00 PM
Hutch,
I draw direct to the desktop no window. I did try a back buffer, and it did not help, I might not of set it up right.
Please look @ my code to see what's wrong.
Thanks
Title: Re: Flicker
Post by: MichaelW on August 28, 2008, 02:01:10 AM
The flicker is a result of redrawing the desktop window ever time the mouse is moved. The attachment contains a modification of your code that uses the simplest method of eliminating the flicker that occurred to me. Basically, it saves the background behind the lines before they are drawn, erases the old lines by restoring the background before drawing the new lines, and never redraws the desktop window.

[attachment deleted by admin]