2words4uready Posted July 15, 2008 Share Posted July 15, 2008 ive got my gui but have no idea how to make it function could someone post a simple example Link to comment Share on other sites More sharing options...
rasim Posted July 15, 2008 Share Posted July 15, 2008 2words4ureadyMore details. Link to comment Share on other sites More sharing options...
2words4uready Posted July 15, 2008 Author Share Posted July 15, 2008 2words4ureadyMore details.how do you make a button actually function like if the user presses the button a message box pops up Link to comment Share on other sites More sharing options...
DaRam Posted July 15, 2008 Share Posted July 15, 2008 how do you make a button actually function like if the user presses the button a message box pops upFrom the Help file: #include <GUIConstantsEx.au3> GUICreate("Hello World", 200, 100) GUICtrlCreateLabel("Hello world! How are you?", 30, 10) $okbutton = GUICtrlCreateButton("OK", 70, 50, 60) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $okbutton MsgBox(0, "GUI Event", "You pressed OK!") Case $msg = $GUI_EVENT_CLOSE MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") ExitLoop EndSelect WEnd Link to comment Share on other sites More sharing options...
Paulie Posted July 15, 2008 Share Posted July 15, 2008 (edited) Or in OnEventMode #include <GUIConstantsEx.au3> Opt('GuiOnEventMode',1) GUICreate("Hello World", 200, 100) GuiSetOnEvent($GUI_EVENT_CLOSE, "Quit") GUICtrlCreateLabel("Hello world! How are you?", 30, 10) $okbutton = GUICtrlCreateButton("OK", 70, 50, 60) GuiCtrlSetOnEvent(-1, "Button") GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func Quit() Exit EndFunc Func Button() MsgBox(0, "", "You pressed the button!") EndFunc Edited July 15, 2008 by Paulie Link to comment Share on other sites More sharing options...
2words4uready Posted July 17, 2008 Author Share Posted July 17, 2008 From the Help file: #include <GUIConstantsEx.au3> GUICreate("Hello World", 200, 100) GUICtrlCreateLabel("Hello world! How are you?", 30, 10) $okbutton = GUICtrlCreateButton("OK", 70, 50, 60) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $okbutton MsgBox(0, "GUI Event", "You pressed OK!") Case $msg = $GUI_EVENT_CLOSE MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") ExitLoop EndSelect WEndim still lost could someone comment the above code and tell me what it does Link to comment Share on other sites More sharing options...
pete1234 Posted July 17, 2008 Share Posted July 17, 2008 (edited) #include <GUIConstantsEx.au3> GUICreate("Hello World", 200, 100); Create the GUI GUICtrlCreateLabel("Hello world! How are you?", 30, 10); Create the label $okbutton = GUICtrlCreateButton("OK", 70, 50, 60); This creates the button. Notice the variable, $okbutton GUISetState(@SW_SHOW); Make the GUI visible While 1 ; Start a loop to keep the GUI visible while it checks to see what the user does $msg = GUIGetMsg(); Watch the GUI to see if the user does anything. Another variable, which will interact with the one above Select Case $msg = $okbutton; If the user clicks the OK button Then... MsgBox(0, "GUI Event", "You pressed OK!"); Display the message box Case $msg = $GUI_EVENT_CLOSE; If user click the GUI's close button Then... MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting..."); Display the message box ExitLoop; Get out of the loop that keeps the GUI visible EndSelect WEnd Edited July 17, 2008 by pete1234 Link to comment Share on other sites More sharing options...
2words4uready Posted July 17, 2008 Author Share Posted July 17, 2008 (edited) #include <GUIConstantsEx.au3> GUICreate("Hello World", 200, 100); Create the GUI GUICtrlCreateLabel("Hello world! How are you?", 30, 10); Create the label $okbutton = GUICtrlCreateButton("OK", 70, 50, 60); This creates the button. Notice the variable, $okbutton GUISetState(@SW_SHOW); Make the GUI visible While 1 ; Start a loop to keep the GUI visible while it checks to see what the user does $msg = GUIGetMsg(); Watch the GUI to see if the user does anything. Another variable, which will interact with the one above Select Case $msg = $okbutton; If the user clicks the OK button Then... MsgBox(0, "GUI Event", "You pressed OK!"); Display the message box Case $msg = $GUI_EVENT_CLOSE; If user click the GUI's close button Then... MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting..."); Display the message box ExitLoop; Get out of the loop that keeps the GUI visible EndSelect WEndthank you so much i was always so lost when working with a gui but i get it now and my programming knowledge is really starting to grow with this language Edited July 17, 2008 by 2words4uready 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