Jump to content

guictrlsetdata flickering


Recommended Posts

a snippet of my code.

Sleep(20)
GUICtrlSetData($mg_ctrl_TimeLabel,"Welcome. Today is the "&@MDAY&"."&@MON&"."&@YEAR&". The time is "&@HOUR&":"&@MIN&":"&@SEC)

the problem is that it flickers. quite noticeably too. right now i'm trying to set the sleep value to something that is both fast to react to buttons being pressed and not to fast so that the message won't flicker as it updates. i've looked in the obvious (to me) parts of the help file for a solution and have yet to find one.

any suggestions?

Link to comment
Share on other sites

Hello GodForsakenSoul,

I noticed that the smallest increment of time to be displayed is a second, have you tried to increase the Sleep to 1000, maybe even 250, should help to reduce or get rid of the flicker, the flicker is from updating 50x per second at a sleep rate of 20ms

Realm

Edit: 250ms should not be a large pause while waiting for a button to be pressed either. thats 4 checks per second.

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
GUICreate("My GUI")
$sec = @SEC
$mg_ctrl_TimeLabel = GUICtrlCreateLabel("", 10, 30, "500")
GUISetState()
Do
    $msg = GUIGetMsg()
    If $sec <> @SEC Then
        $sec = @SEC
        GUICtrlSetData($mg_ctrl_TimeLabel,"Welcome. Today is the "&@MDAY&"."&@MON&"."&@YEAR&". The time is "&@HOUR&":"&@MIN&":"&@SEC)
    EndIf
Until $msg = $GUI_EVENT_CLOSE

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

  • Moderators

GodForsakenSoul,

The normal trick to prevent this is to change the data only when it needs changing. In this case the @SEC is changing the most rapidly so I would suggest something along these lines (untested):

$iSec = 0
; Start Loop

If @SEC <> $iSec Then
    $iSec = @SEC
    GUICtrlSetData(.....)
EndIf

; End Loop

Now you only update when @SEC changes once per second and the flickering should stop. ;)

A similar trick can be used if you have to change the state of a control - just check the current state and only change state if required. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

GodForsakenSoul,

bogQ suggested it as well - so you have a double problem! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Here another method:

#include <GUIConstantsEx.au3>
GUICreate("My GUI")
$mg_ctrl_TimeLabel = GUICtrlCreateLabel("", 10, 30, "500")
GUISetState()

Update()
AdlibRegister("Update", 500)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

AdlibUnRegister("Update")
Exit

Func Update()
    GUICtrlSetData($mg_ctrl_TimeLabel,"Welcome. Today is the "&@MDAY&"."&@MON&"."&@YEAR&". The time is "&@HOUR&":"&@MIN&":"&@SEC)
EndFunc

But it still flickers sometimes -> bogQ example is much better.

Br,

UEZ

Edited by UEZ

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...