Can I use WM_COMMAND to handle EN_CHANGE message but not BN_CLICKED? As long WM_COMMAND process the message BN_CLICKED I am not able to catch the button click in loop using GUIGetMsg().
AutoIt
#include <WindowsConstants.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <WinAPI.au3> $hMain = GUICreate("Test",400,400) $hButton = GUICtrlCreateButton("Click Me",100,100,100,30) $hInput = GUICtrlCreateInput("",100,200,100,30) GUIRegisterMsg($WM_COMMAND,'WM_COMMAND') GUISetState(@SW_SHOW,$hMain) While True Switch GUIGetMsg() Case $hButton MsgBox(0,"Message","You just clicked me.") Case -3 ; GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Switch _WinAPI_HiWord($wParam) Case $EN_CHANGE TrayTip("Read",GUICtrlRead(_WinAPI_LoWord($wParam)),1) Return 0 EndSwitch Return _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam) EndFunc
EDIT: I got this working in this way but I'm looking for something more elegant
AutoIt
#include <WindowsConstants.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <WinAPI.au3> $hMain = GUICreate("Test",400,400) $hButton = GUICtrlCreateButton("Click Me",100,100,100,30) $hInput = GUICtrlCreateInput("",100,200,100,30) $hDummy = GUICtrlCreateDummy() GUIRegisterMsg($WM_COMMAND,'WM_COMMAND') GUISetState(@SW_SHOW,$hMain) While True Switch GUIGetMsg() Case $hDummy Switch GUICtrlRead($hDummy) Case $hButton MsgBox(0,"Message","You just clicked me.") EndSwitch Case -3 ; GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Switch _WinAPI_HiWord($wParam) Case $EN_CHANGE TrayTip("Read",GUICtrlRead(_WinAPI_LoWord($wParam)),1) Return 0 Case $BN_CLICKED GUICtrlSendToDummy($hDummy,_WinAPI_LoWord($wParam)) EndSwitch Return _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam) EndFunc