MirnesC2 Posted October 18, 2009 Share Posted October 18, 2009 (edited) Hi, well I have a code its set up something like this... ; some gui stuff here ; buttons, labels, bla bla While 1 $msg = GUIGetMsg() If $msg = $edit Then Call("EditPanel") EndIf If $msg = $save Then MsgBox(48, "Saved", "Save Completed", 10) Until $msg = $msg = $GUI_EVENT_CLOSE Func EditPanel() ;some gui stuff here ;other code bla bla If $msg = $close OR $msg = $GUI_EVENT_CLOSE Then GUIDelete("EditPanel") EndIf EndFunc It's basically a main GUI panel with a bunch of options such as... save and edit. When you press edit it opens a new window, all the new window gui and code is inside the function EditPanel(). Now I figured out how to delete the gui of the EditPanel() but it's still inside the function so the buttons from the main GUI menu still don't work. My questions is what do I add after GUIDelete("EditPanel") to exit the function EditPanel() and go back to the main menu/GUI. Or is there an easier way to do this? Edited October 18, 2009 by MirnesC2 Link to comment Share on other sites More sharing options...
martin Posted October 18, 2009 Share Posted October 18, 2009 Hi, well I have a code its set up something like this... ; some gui stuff here ; buttons, labels, bla bla While 1 $msg = GUIGetMsg() If $msg = $edit Then Call("EditPanel") EndIf If $msg = $save Then MsgBox(48, "Saved", "Save Completed", 10) Until $msg = $msg = $GUI_EVENT_CLOSE Func EditPanel() ;some gui stuff here ;other code bla bla If $msg = $close OR $msg = $GUI_EVENT_CLOSE Then GUIDelete("EditPanel") EndIf EndFunc It's basically a main GUI panel with a bunch of options such as... save and edit. When you press edit it opens a new window, all the new window gui and code is inside the function EditPanel(). Now I figured out how to delete the gui of the EditPanel() but it's still inside the function so the buttons from the main GUI menu still don't work. My questions is what do I add after GUIDelete("EditPanel") to exit the function EditPanel() and go back to the main menu/GUI. Or is there an easier way to do this? I assume your real code has the If/GuiDelete/endif inside a while loop, otherwise the function as you've shown it will just end and return to the main script. Best not have the same variable name ($msg) in the function to avoid problems. Better to declare a local variable in the function with a different name. Anyway, to return from a function just use Return. If $timetoleave Then cleanup() Return EndIf BTW, there is no advantage in using Call instead of the function name. EditPanel(); better than Call("EditPanel") Call is useful when you need a variable for the function name. I can't think of any other reason to use it at the moment. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
MirnesC2 Posted October 18, 2009 Author Share Posted October 18, 2009 I assume your real code has the If/GuiDelete/endif inside a while loop, otherwise the function as you've shown it will just end and return to the main script. Best not have the same variable name ($msg) in the function to avoid problems. Better to declare a local variable in the function with a different name. Anyway, to return from a function just use Return. If $timetoleave Then cleanup() Return EndIf BTW, there is no advantage in using Call instead of the function name. EditPanel(); better than Call("EditPanel") Call is useful when you need a variable for the function name. I can't think of any other reason to use it at the moment. Oh!, Return... so simple, lol. I accidentally hit the - reputation button, but I went back to some of your others posts and hit the + to re-balance it. Sorry, they really need a confirmation window or undo button on that thing o.o Thank you!, and thanks for the call function tip. Link to comment Share on other sites More sharing options...
MirnesC2 Posted October 24, 2009 Author Share Posted October 24, 2009 I got it working, thanks. One more problem though. Lets say I have the main gui/panel/frame. It has a label that says "hello". Now I got to 2nd gui/panel/frame and edit it to say "whats up" instead of hello. When I save and exit out the 2nd gui/panel/frame the label "hello" on main frame still says "hello" instead of "whats up". How can I fix that? How can make it update or reset the gui? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 24, 2009 Moderators Share Posted October 24, 2009 MirnesC2,Look at GUICtrlSetData in the Help file.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MirnesC2 Posted October 24, 2009 Author Share Posted October 24, 2009 MirnesC2,Look at GUICtrlSetDatain the Help file.M23It shows an example with combo box, I don't really understand it. Is it possible to make an example with label instead? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 24, 2009 Moderators Share Posted October 24, 2009 MirnesC2, Click either the button or the label itself: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hLabel = GUICtrlCreateLabel("First line of text", 10, 10, 300, 30) $hButton = GUICtrlCreateButton("Change", 10, 50, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton, $hLabel If GUICtrlRead($hLabel) = "First line of text" Then GUICtrlSetData($hLabel, "Second line of text") Else GUICtrlSetData($hLabel, "First line of text") EndIf EndSwitch WEnd To really understand functions you need to play with the Help file examples and see what results you get. It is the best way to learn. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
MirnesC2 Posted October 24, 2009 Author Share Posted October 24, 2009 Ah, great! Thank you so much, I got it to work now. Link to comment Share on other sites More sharing options...
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