tamir Posted January 6, 2005 Posted January 6, 2005 i have a function Func test($var) MsgBox(0, "", $var) EndFunc i want to make 2 buttons: 1 that calls to test("a") and the other that calls to test("b"). after i made the 2 buttons, how do i make them call to the function with the variables? the second is if i can let the user select more then 1 option in GUICtrlCreateList?
layer Posted January 6, 2005 Posted January 6, 2005 (edited) like this ? (from helpfile and me) GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered Opt("GUICoordMode",2) $a= GUICtrlCreateButton ("A", 10, 30, 50) $b= GUICtrlCreateButton ( "B", 0, -1) GUISetState () ; will display an dialog box with 2 button ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg= $a then MsgBox (0, "A", "A") If $msg= $b then MsgBox (0, "B", "B") Wend Edited January 6, 2005 by layer FootbaG
tamir Posted January 6, 2005 Author Posted January 6, 2005 well, not exactly but from your code i know how to do this... i forgot about GUIGetMsg(). thanks. now i need to know about the second question
layer Posted January 6, 2005 Posted January 6, 2005 hehe, no problem, whats your second problem? FootbaG
tamir Posted January 7, 2005 Author Posted January 7, 2005 it's written in the topic... and i have another problem: what's wrong with this? $par_a = "" $par = "a" $open = "text" Eval("par_" & $par) = $open i get the error: Illegal text at the end of statement (one statement per line)
SlimShady Posted January 7, 2005 Posted January 7, 2005 The only thing Eval does is return the value of the variable. You can't assign a value to a variable using Eval. You will need to use Assign for that. $par_a = "" $par = "a" $open = "text" Assign("par_" & $par, $open) If you get an error message, check the help file for more info. If that's not enough, ask here.
Administrators Jon Posted January 7, 2005 Administrators Posted January 7, 2005 You can also use the Event mode rather than GuiGetMsg which is sometimes easier to understand: Look up GuiCtrlSetOnEvent which gives this example: #include <GUIConstants.au3> Opt("GUICoordMode",2) Opt("GuiOnEventMode", 1) $parent1 = GuiCreate("Parent1") $ok1 = GUICtrlCreateButton ("OK", 10, 30, 50) GUICtrlSetOnEvent(-1, "OKPressed") $cancel1 = GUICtrlCreateButton ( "Cancel", 0, -1) GUICtrlSetOnEvent(-1, "CancelPressed") GuiSetState(@SW_SHOW) ; Just idle around While 1 Sleep(10) Wend ; END Func OKPressed() MsgBox(0, "OK Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE) EndFunc Func CancelPressed() MsgBox(0, "Cancel Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE) EndFunc You can only specify a function to call (no parameters) but for your case you could easily do something like this, Func TestA() Test("a") EndFunc Func TestB() Test("b") EndFunc Func Test($var) MsgBox(0, "", $var) EndFunc Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/
tamir Posted January 7, 2005 Author Posted January 7, 2005 i know but the GUIGetMsg is better in my opinion
tamir Posted January 7, 2005 Author Posted January 7, 2005 umm can any1 answer my first question plz?
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