Faalamva Posted February 17, 2013 Share Posted February 17, 2013 Hello, I have an EditBox that I'm using as input for a search function :$MySearch = GUICtrlCreateEdit(...)Next to it, I have a button that I click once the occurrence to be searched has been entered in the editbox.When clicking this button, a listbox displays the result of the search.It works, but now I would like to improve this a bit. I want to avoid clicking on a button to launch the search (lazy me >_<).I would like that whenever I type a new character (or delete a character) in the editbox, the search is triggered and the listbox is updated with the corresponding search result.How could I do that ?Thank you ! Link to comment Share on other sites More sharing options...
kylomas Posted February 18, 2013 Share Posted February 18, 2013 Faalamva, You can use this technique #Include <GUIConstants.au3> #Include <EditConstants.au3> #Include <WindowsConstants.au3> #Include <winapi.au3> GUICreate('MyGUI', 300, 200) $Input = GUICtrlCreateInput('', 10, 10, 280, 19) $edit = guictrlcreateedit("",10,40,100,20) GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Switch BitAND($wParam, 0xFFFF) Case $Input Switch BitShift($wParam, 16) Case $EN_CHANGE ConsoleWrite("from en_change > " & GUICtrlRead($Input) & @CR) Case $EN_update ConsoleWrite("from en_update > " & GUICtrlRead($Input) & @CR) EndSwitch EndSwitch Return $GUI_RUNDEFMSG endfunc kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 18, 2013 Moderators Share Posted February 18, 2013 Faalamva,You might find the GUIRegisterMsg tutorial in the Wiki a good starting point to understand Windows message handling. M23 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...
Faalamva Posted February 22, 2013 Author Share Posted February 22, 2013 (edited) Thank you both ! Melba23, your tutorial was very helpful. Without it, I would never have figured what kylomas cryptic code was doing ! I have adapted kylomas code to my own program, and it works like a charm.However, I still have a few questions :What is the difference between EN_CHANGE and EN_UPDATE ? I have kept only EN_CHANGE because whenever I updated my EditZone, both types or messages were called, which resulted in my handling function to be called twice...I have commented the last line (the Return $GUI_RUNDEFMSG) because according to the tutorial, this can lead to unstable system behaviour. Not that my handling function may take a very long time to execute (less than 1 second), but from what I understand, this return instruction is simply an optimization, but not required, to avoid the whole system applications to check the notification that is supposed to concern only my AutoIt application anyway, am I right ?Cheers ! Edited February 22, 2013 by Faalamva Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 22, 2013 Moderators Share Posted February 22, 2013 Faalamva- 1. Welcome the to world of MSDN - read about these messages (and all the others!) here! - 2. You have misunderstood the tutorial. Returning $GUI_RUNDEFMSG just tells AutoIt to pass the message on as usual to Windows itself and any other controls that might require it. Returning 0 tells AutoIt not to do this (and so prevent the focus lines showing as in my UDF ). The system will become unstable if you spend too long (I use about 500ms as an absolute max) inside the handler without returning either of the above values. The tutorial shows how to use flags and dummy controls to run long complicated functions outside the handler, but triggered by it.All clear now ? M23 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...
Faalamva Posted February 25, 2013 Author Share Posted February 25, 2013 I wouldn't say it's all clear, but at least it's clearer ! Gotta check MSDN from time to time, depending on my needs. For now, the parts of my program that needed message handling are OK, thank you for your help and great links as usual ! 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