Sign in to follow this  
Followers 0
KaFu

Use input control as fake label to avoid flickering on update

6 posts in this topic

#1 ·  Posted (edited)

One more work-around for the old problem :). Update procedure must be quite different for these two control types under the hood.

 

#include <WindowsConstants.au3>
#include <EditConstants.au3>

HotKeySet("{ESC}", "_Exit")

GUICreate("My GUI")
GUISetBkColor(0x00ff00)

$c_Label = GUICtrlCreateLabel(0, 10, 10, 200, 20)

$c_Input = GUICtrlCreateInput(0, 10, 60, 200, 20, $ES_READONLY, $WS_EX_TRANSPARENT)
GUICtrlSetBkColor(-1, 0x00ff00)
GUICtrlSetCursor(-1, 2) ; Arrow

GUISetState(@SW_SHOW)

While 1
    GUICtrlSetData($c_Label, TimerInit())
    GUICtrlSetData($c_Input, TimerInit())
WEnd

Func _Exit()
    Exit
EndFunc   ;==>_Exit

 

Edited by KaFu
4 people like this

Share this post


Link to post
Share on other sites



Nice catch KaFu :thumbsup:

Here an additional one:

#include <WindowsConstants.au3>
#include <EditConstants.au3>

HotKeySet("{ESC}", "_Exit")

GUICreate("My GUI", 300, 200, -1, -1, -1, BitOR($WS_EX_LAYERED, $WS_EX_COMPOSITED))
GUISetBkColor(0x00ff00)

$c_Label = GUICtrlCreateLabel(0, 10, 10, 200, 20)

$c_Input = GUICtrlCreateInput(0, 10, 60, 200, 20) ;, $ES_READONLY, $WS_EX_TRANSPARENT)
GUICtrlSetBkColor(-1, 0x00ff00)
GUICtrlSetCursor(-1, 2) ; Arrow

GUISetState(@SW_SHOW)

While 1
    GUICtrlSetData($c_Label, TimerInit())
    GUICtrlSetData($c_Input, TimerInit())
WEnd

Func _Exit()
    Exit
EndFunc   ;==>_Exit

 

4 people like this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Really great idea, at least this way you wouldn't have to add code to check to see if the value has changed just to avoid the flickering.

When you click on the title bar it freezes the display, and one thing I noticed when I changed the code to what's below, that the Input control almost always has an earlier TimerDiff value than the label does even though it's in the script after the update to the label.

While 1
    GUICtrlSetData($c_Label, TimerDiff($Timer))
    GUICtrlSetData($c_Input, TimerDiff($Timer))
WEnd

 


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Nice catch KaFu :thumbsup:

Here an additional one:

Hi UEZ.  Why does this work: BitOR($WS_EX_LAYERED, $WS_EX_COMPOSITED))  ???

 

Thanks to you both!

Share this post


Link to post
Share on other sites

According to MS

WS_EX_COMPOSITED (0x02000000):

Paints all descendants of a window in bottom-to-top painting order using double-buffering. For more information, see Remarks. This cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC.

Windows 2000:  This style is not supported.

WS_EX_COMPOSITED works by forcing child windows to draw back to front and by double buffering them; however, the double buffering used by WS_EX_COMPOSITED for the child windows conflicts with the double buffering used by WS_EX_LAYERED windows and DWM so it does not remove the flicker in those contexts.

 

Unfortunately, this means that your composited test application flickers with DWM turned on but not with DWM turned off.

 

Narrowing the area invalidated to the minimum necessary and using WS_CLIPCHILDREN and WS_CLIPSIBLINGS appropriately can help reduce the amount of flicker.

    WS_EX_COMPOSITED does not eliminate flashing on Windows 8 with DWM (Desktop Windows Manager)

WS_EX_COMPOSITED appears to work fine until you minimize then restore the window.  Then the child windows will start flashing.  To avoid flashing do not set the WS_EX_COMPOSITED style, do your own double buffering, and ignore the WM_ERASEBKGND message.  This is a know issue with Microsoft. 

 

WS_EX_LAYERED (0x00080000):

The window is a layered window. This style cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC.

Windows 8:  The WS_EX_LAYERED style is supported for top-level windows and child windows. Previous Windows versions support WS_EX_LAYERED only for top-level windows.

WS_EX_LAYERED windows and all windows when DWM is enabled are rendered into an offscreen buffer and that buffer is then rendered to the screen.  WM_PAINT messages can be skipped to update the onscreen buffer so long as the offscreen buffer is valid.

 

Maybe this helps a little bit.


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Thank you for the thorough answer!

Appreciate your input as always!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0