Sven Posted November 3, 2014 Share Posted November 3, 2014 I've set up a control with GUICtrlCreateInput("", $x, $y, $width, $height) GUICtrlSetLimit(-1, 1) Is there a way to erase the current content automatically when new data is entered? I know of GUICtrlSendMsg() and $EM_SETSEL, but this causes flickering in the input control when placed in a while loop. Enter "1" in the input control, "1" stays. Try entering "2", and "1" is replaced by it. Link to comment Share on other sites More sharing options...
jdelaney Posted November 3, 2014 Share Posted November 3, 2014 Logically only set the value when it's NOT what you are changing it to. No flashing that way. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
johnmcloud Posted November 3, 2014 Share Posted November 3, 2014 (edited) ; Johnmcloud - 2014 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> $hGUI = GUICreate("Johnmcloud Test Code", 200, 70, -1, -1) $sInput = GUICtrlCreateInput("", 10, 20, 180, 20) GuiSetState() GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $iIDFrom = BitAND($wParam, 0xFFFF);LoWord Local $iCode = BitShift($wParam, 16) ;HiWord If $iIDFrom = $sInput And $iCode = $EN_CHANGE Then GUICtrlSetData($sInput, StringRight(GUICtrlRead($sInput),1)) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND Edited November 3, 2014 by johnmcloud MikahS 1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 3, 2014 Moderators Share Posted November 3, 2014 Sven,Fun little problem that one! How about this as a solution: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIEdit.au3> ; Create a flag Global $iFocused = 0 $hGUI = GUICreate("Test", 500, 500) $cInput = GUICtrlCreateInput("", 10, 10, 200, 20) GUICtrlSetLimit($cInput, 1) $cButton = GUICtrlCreateButton("Test", 10, 100, 80, 30) GUICtrlSetState($cButton, $GUI_FOCUS) GUISetState() GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch If $iFocused = 1 Then _GUICtrlEdit_SetSel($cInput, 0, -1) ; Set flag for focused and selected $iFocused = 2 EndIf WEnd Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Switch _WinAPI_HiWord($wParam) ; Code Case $EN_SETFOCUS If Not $iFocused Then ; Set flag for initial focus $iFocused = 1 EndIf Case $EN_KILLFOCUS ; Clear flag $iFocused = 0 EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMANDNow you only select the content when you initially focus on the input. Any use? M23 MikahS 1 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Sven Posted November 3, 2014 Author Share Posted November 3, 2014 There I was, thinking the solution would just be a flag or command that I don't know about johnmcloud's solution is working is pretty ideal for my purposes. Thank you. Looking at your example, I ended up putting three more lines into the while loop of my code: If StringLen(GUICtrlRead($id) > 1 Then GUICtrlSetData($id, StringRight(GUICtrlRead($id), 1)) EndIf Link to comment Share on other sites More sharing options...
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