Jump to content
Sign in to follow this  
infernothebest

flikker text

Recommended Posts

infernothebest

i have a problem i wanna count the lengt from text in my sms prog, the problem is it flickers because it calulate the hole time i inigrate this script in the while from my gui, anyone a idea to fix this? i tryed sleep this works but the gui is verry slow then

$length = StringLen(GuiCtrlRead($TEXT)) 
GUICtrlSetData ($Characters,"Totaal Char: "&$length)
For $i = 1 To string($length/161)+1
$y  =String(160*$i-$length)
GUICtrlSetData($SMS,"SMS: "&$i&"  Remaining Char: "&$y)

Share this post


Link to post
Share on other sites
bluelamp

at the start of the loop you do something like this:

$timer = Timerinit()

and in the loop you test the expired time like this:

if Timerdiff($imer) > $x then

; your stringcode

$timer = Timerinit() ; reinitialize Timer

endif

$x is the time it waits

Edited by bluelamp

Share this post


Link to post
Share on other sites
zorphnog

The best way around this is to register a _WM_COMMAND function to notify your script when the text changes for your input.

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

$gMain = GUICreate("_WM_COMMAND Example", 362, 150, -1, -1, BitOR($WS_MINIMIZEBOX,$WS_CAPTION,$WS_POPUP,$WS_MAXIMIZEBOX))
GUICtrlCreateLabel("String:", 31, 8, 34, 17, $SS_RIGHT)
$edString = GUICtrlCreateEdit("", 72, 8, 265, 73, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
$lbCount = GUICtrlCreateLabel("Count: 0", 24, 90, 100, 17)

$bTyped = False
GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $bTyped
            GUICtrlSetData($lbCount, "Count: " & StringLen(GUICtrlRead($edString)))
            $bTyped = Not $bTyped
    EndSelect
WEnd

Func _WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nNotifyCode = BitShift($wParam, 16)
    Local $nID = BitAND($wParam, 0xFFFF)

    Switch $nID
        Case $edString
            If $nNotifyCode = $EN_CHANGE Then $bTyped = True
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc  ;==>MY_WM_COMMAND

Share this post


Link to post
Share on other sites
dbzfanatic

I say the easiest way is to store the previous value into a variable then compare the previous value and the current one. If it's changed then update the label and save the current value to the variable.

Share this post


Link to post
Share on other sites
Pain

Use ControlSetText() instead of GuiCtrlSetData() and only update if data has changed.

Share this post


Link to post
Share on other sites
trancexx

Use ControlSetText() instead of GuiCtrlSetData() ...

Why?

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Pain

First try this one, then uncomment ControlSetText() and comment GUICtrlSetData() and see if there is any difference.

#include <GUIConstants.au3>

GUICreate("test")
$label = GUICtrlCreateLabel("0", 150, 150, 100, 100)
GUICtrlSetColor($label, 0xFF0000)
GUICtrlSetBkColor($label, 0xFFFFFF)
GUISetState()

Local $count = 0

While 1
    $msg = GUIGetMsg ()
    If $msg = $GUI_EVENT_CLOSE Then
        ExitLoop
    EndIf
    $Count += 1
    GUICtrlSetData($label, $count)
;~  ControlSetText("test", "", "Static1", $count)
WEnd

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.