Jump to content
Sign in to follow this  
jercfd

detect change on edit control

Recommended Posts

jercfd

How would I detect a change on an edit control. For example, when I type something into the edit control, it will do a function but when not typing, it will not. I know that putting the function in the While section will work but I do not want to always call it when typing is inactive.

Share this post


Link to post
Share on other sites
dbzfanatic
jercfd

Add Case $editname To your while and add your function code under it.

That way only works if I press enter on the edit control. I want the information to be displayed instantly.

Share this post


Link to post
Share on other sites
BAM5

You could do a

GUICtrlReadoÝ÷ ÚÚ+zÚâz÷­çZµ«azw(«z+m£Z·¬¦·¯¬,+Û^LZ^jëh×6If GUICtrlRead($editname) = $old Then
[indent]$old=GUICtrlRead($editname)[/indent]
Else
[indent]$old=GUICtrlRead($editname)
TheFunction()[/indent]
EndIf

(WHY DO YOU FAIL ME INDENT TABS?!?! WHY!?!?!?!)

You'd put the above code in your while and be sure to say something like $old="" or Local $old before the while so you don't get an error that the variable doesn't exist.

Edited by bam5

[center]JSON Encoding UDF[/center]

Share this post


Link to post
Share on other sites
jercfd

I know your code will work but I don't always want to see if it has changed. It will cause higher CPU usage. I'm not too sure if it is possible but can you use GUIRegisterMsg.

Share this post


Link to post
Share on other sites
rasim

jercfd

Try this:

#include <GuiConstantsEx.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>

$hGui = GUICreate("Test GUI", 300, 200)

$hEdit = GUICtrlCreateEdit("", 10, 10, 280, 180)

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState()

While GUIGetMsg() <> -3
    ;
WEnd

Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $IdFrom, $iCode
    
    $IdFrom = BitAnd($wParam, 0x0000FFFF)
    $iCode = BitShift($wParam, 16)
    
    Switch $IdFrom
        Case $hEdit
            Switch $iCode
                Case $EN_UPDATE
                    ConsoleWrite("!> Changes on edit control detected" & @LF)
            EndSwitch
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc

;)

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.