Hallo,
ich habe eine Problem bei GUI Event Handling im nachfolgenden Beispiel. Im GUI gibt es mehrere Eingabefelder, in denen editiert werden kann. Ich suche eine Möglichkeit herauszufinden, in welchem Feld zuletzt editiert wurde. Gibt es einen "GUI Event", der anzeigt, dass in ein bestimmtes Eingabefeld "geclickt" wurde, und den ich mit der Funktion EditClicked() verbinden könnte?
[autoit]#include <GuiConstants.au3>
Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
; Create overall GUI dialog
Local Const $gw = 550
Local Const $gh = 500
Local $hGUI = GUICreate("Edit Controls Test", $gw, $gh, (@DesktopWidth - $gw) / 2, (@DesktopHeight - $gh) / 2)
; Create input edit fields
Local $nEdits = 4
Local $aEdit[$nEdits]
$aEdit[0] = GUICtrlCreateEdit("", 10, 10, 400, 100, BitOR($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL))
$aEdit[1] = GUICtrlCreateEdit("", 10, 120, 400, 100, BitOR($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL))
$aEdit[2] = GUICtrlCreateEdit("", 10, 230, 400, 100, BitOR($ES_WANTRETURN, $WS_HSCROLL, $ES_AUTOHSCROLL))
$aEdit[3] = GUICtrlCreateEdit("", 10, 340, 400, 100, BitOR($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL))
; Create buttons
$h_Exit = GUICtrlCreateButton("Exit", 70, 460, 50, 21)
$h_Act = GUICtrlCreateButton("Activate", 10, 460, 50, 21)
; Associate events
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitClicked")
GUICtrlSetOnEvent($h_Exit, "ExitClicked")
GUICtrlSetOnEvent($h_Act, "ActionClicked")
; Now show the GUI
GUISetState(@SW_SHOW)
Global $bExit = False
While Not $bExit
Sleep(1000) ; Idle around
WEnd
Exit
Func ExitClicked() ; handle click on exit button or window close
MsgBox(0, "GUI Event", "You pressed Exit!", 2)
$bExit = True
EndFunc
Func ActionClicked() ; handle click on action button
MsgBox(0, "GUI Event", "You pressed Action!", 2)
EndFunc
Func EditClicked() ; hanlde click into edit field
MsgBox(0, "GUI Event", "You clicked edit control " & @GUI_CTRLID, 2)
$bExit = True
EndFunc
Mit freundlichen Grüßen - Tom