Jump to content

Is there a on change event?


XGamerGuide
 Share

Recommended Posts

WM_COMMAND message is what you are looking at :

  • For combo, it is the CBN_SELCHANGE notification (with CBS_DROPDOWNLIST)
  • For edit (input), it is the EN_UPDATE or EN_CHANGE notification.

You simply need to register the message thru GUIRegisterMsg and intercept the modifications.  Search forum, as there are tons of examples...

Edited by Nine
Link to comment
Share on other sites

Nine's suggestion of using WM_COMMAND is absolutely the best way of accomplishing your task. However, I know it can be difficult to implement, so I offer an easier, but less effective method. That being said, I think you should use WM_COMMAND instead of my own suggestion.

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 292, 213)
$Combo1 = GUICtrlCreateCombo("", 64, 32, 145, 25)
GUICtrlSetData(-1, "test|test2|test3")
$Label1 = GUICtrlCreateLabel("", 64, 64, 200, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000080)
$Input1 = GUICtrlCreateInput("", 64, 104, 121, 21)
$Label2 = GUICtrlCreateLabel("", 64, 136, 200, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x008000)
$Button1 = GUICtrlCreateButton("Exit", 184, 168, 75, 25, $WS_GROUP)
$dummy = GUICtrlCreateDummy()
GUISetState(@SW_SHOW)

 Local $aAccelKeys[1][2] = [["{ENTER}", $dummy]] ; when you press ENTER, the combobox & inputbox will update.
GUISetAccelerators($aAccelKeys)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Exit
        Case $Combo1
            GUICtrlSetData($Label1, GUICtrlRead($Combo1))
        Case $dummy
            GUICtrlSetData($Label1, GUICtrlRead($Combo1))
            GUICtrlSetData($Label2, GUICtrlRead($Input1))
    EndSwitch
WEnd

 

Link to comment
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
 Share

×
×
  • Create New...