infernothebest Posted September 29, 2008 Posted September 29, 2008 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) Apple Keybord shortcuts for XP
bluelamp Posted September 29, 2008 Posted September 29, 2008 (edited) 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 September 29, 2008 by bluelamp
zorphnog Posted September 29, 2008 Posted September 29, 2008 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
infernothebest Posted September 29, 2008 Author Posted September 29, 2008 thx all for the replys iam going to test it now:) i let you hear someting:) if it worked or not:D Apple Keybord shortcuts for XP
dbzfanatic Posted September 29, 2008 Posted September 29, 2008 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. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote]
Pain Posted September 29, 2008 Posted September 29, 2008 Use ControlSetText() instead of GuiCtrlSetData() and only update if data has changed.
trancexx Posted September 29, 2008 Posted September 29, 2008 Use ControlSetText() instead of GuiCtrlSetData() ...Why? ♡♡♡ . eMyvnE
Pain Posted September 29, 2008 Posted September 29, 2008 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
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