lemony Posted May 20, 2008 Posted May 20, 2008 I call it the flicker of death. #include <GUIConstants.au3> Global $var = 0 GUICreate ("flicker of death", 200, 40) $label = GUICtrlCreateLabel ("", 0, 0, 200, 40) GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetColor(-1, 0xFFFFFF) GUISetState () While 1 $msg = GUIGetMsg () If $msg = $GUI_EVENT_CLOSE Then ExitLoop EndIf $var += 1 GUICtrlSetData($label, $var) WEnd
Tomb Posted May 20, 2008 Posted May 20, 2008 add sleep(100) in the while loop.or whatever amount you want to sleep really.it will cut down on cpu usage and flash less.
lemony Posted May 20, 2008 Author Posted May 20, 2008 add sleep(100) in the while loop.or whatever amount you want to sleep really.it will cut down on cpu usage and flash less.Well, I gotta say, this DOES work. Although it is no longer "rapid updating".Anyway, from all the posts I read about this when searching, this seems to be the only solution.Thanks for your time!
Siao Posted May 20, 2008 Posted May 20, 2008 (edited) Use ControlSetText instead of GUICtrlSetData. Update only if new text is different from old text (in your example it always is, so this point is irrelevant, but in other uses it may not). That's just common sense. Also, if you want to do it from the main loop, use event mode. Otherwise, adlib or timer. If you do in GuiGetMsg loop, the frequency it triggers depends on messages generated for the window. In idle mode it's ~10ms, much more if you move mouse over GUI. Unless the purpose of your counter is to count GUI events, such disparity isn't useful at all. Edited May 20, 2008 by Siao "be smart, drink your wine"
lemony Posted May 21, 2008 Author Posted May 21, 2008 ControlSetText makes it flicker-free Nice one! And yeah, I will be switching it to on event mode. Thanks for the advice and for solving this one for me!
dmob Posted June 5, 2008 Posted June 5, 2008 Nice one, guys. How do I stop the flicker when loading a ListView. I tried adding the sleep, but it still flickers.
rasim Posted June 5, 2008 Posted June 5, 2008 dalisuitHow do I stop the flicker when loading a ListView. I tried adding the sleep, but it still flickers._GUICtrlListView_BeginUpdate()_GUICtrlListView_EndUpdate()
dmob Posted June 5, 2008 Posted June 5, 2008 Thanks Rasim for pointing me in the right direction, I will try that.
koresho Posted September 30, 2011 Posted September 30, 2011 I know this is somewhat of a necro, but I'm adding this in case others Google this and find this topic like I did. I ran into a similar problem using a script that was reading lines in an excel file. Here is how I resolved the issue: $time = TimerInit() For $row = "1" To $totalRows $num = $num + _ExcelReadCell($book, $row, 8) $diff = TimerDiff($time) If $diff > 100 Then GUICtrlSetData($lbl2, "Reading line " & $row & " of " & $totalRows & ", " & $num & " Projects") $time = TimerInit() EndIf Next With the wait set to 50ms, the update speed didn't look any different visually to me, so if you want it to look completely smooth you can set it to that.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now