eJan Posted February 3, 2006 Posted February 3, 2006 I'm trying to change style or delete controls created inside function using variables, but error was "Error: Variable used without being declared" - see: ;If $msg = $delbtn Then DeleteLabel() #include <GUIConstants.au3> GUICreate("My GUI", 120, 170) GUISetState (@SW_SHOW) $btn = GUICtrlCreateButton("Create label", 25, 120, 70, 20) While 1 $msg = GUIGetMsg() If $msg = $btn Then _CreateLabel() ;If $msg = $delbtn Then DeleteLabel(); If enabled "Error: Variable used without being declared" If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Func _CreateLabel() $label = GUICtrlCReateLabel("Label", 10, 10, 100, 100, $SS_SUNKEN) $delbtn = GUICtrlCreateButton("Delete label", 25, 140, 70, 20) EndFunc Func DeleteLabel() GUICtrlDelete($label) EndFunc
SandelPerieanu Posted February 3, 2006 Posted February 3, 2006 #include <GUIConstants.au3>Global $delbtn, $label, $btnGUICreate("My GUI", 120, 170)GUISetState(@SW_SHOW)$btn = GUICtrlCreateButton("Create label", 25, 120, 70, 20)While 1 $msg = GUIGetMsg() If $msg = $btn Then _CreateLabel() If $msg = $delbtn Then DeleteLabel(); If enabled "Error: Variable used without being declared" If $msg = $gui_event_close Then ExitLoopWEndFunc _CreateLabel() $label = GUICtrlCreateLabel("Label", 10, 10, 100, 100, $ss_sunken) $delbtn = GUICtrlCreateButton("Delete label", 25, 140, 70, 20)EndFunc ;==>_CreateLabelFunc DeleteLabel() GUICtrlDelete($label) GUICtrlDelete($delbtn)EndFunc ;==>DeleteLabel
eJan Posted February 3, 2006 Author Posted February 3, 2006 Thanks psandu.ro, thats exactly what I need!
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