Guest Posted April 12, 2017 Share Posted April 12, 2017 (edited) Instead of writing something like this: expandcollapse popupGlobal $MainMSG ; Global massage for use on any gui function Func MainGUI() $MainGUI = GUICreate('Main') $SettingsGUI = SettingsGUI_Create($MainGUI) ; Create child windo inside the main GUI SettingsGUI_DrawSettings() $OtherGUI = OtherGUI_Create($MainGUI) ; Create child windo inside the main GUI $MainMSG = GUIGetMsg(1) While 1 SettingsGUI_MonitorChanges() ; If some data on the inputs in the SettingsGUI was changed then do something... Switch $MainMSG[1] Case $MainGUI ; Do stuff about the main gui Case $SettingsGUI SettingsGUI_ProcessMSG() SettingsGUI_DoSomeThingElse() Case $OtherGUI OtherGUI_ProcessMSG() OtherGUI_DoSomeThingElse() EndSwitch WEnd EndFunc Func SettingsGUI_Create($hPerentGUI) ; Create and return the child gui EndFunc Func SettingsGUI_MonitorChanges() EndFunc Func SettingsGUI_ProcessMSG() EndFunc Func SettingsGUI_DrawSettings() ; Draw settings of the controls.. EndFunc Func SettingsGUI_DoSomeThingElse() EndFunc Func OtherGUI_ProcessMSG() EndFunc Func OtherGUI_DoSomeThingElse() EndFunc expandcollapse popupGlobal $MainMSG ; Global massage for use on any gui function Func MainGUI() $MainGUI = GUICreate('Main') #NameSpace $SettingsGUI = Create($MainGUI) ; Create child windo inside the main GUI DrawSettings() #NameSpaceEnd $OtherGUI = OtherGUI_Create($MainGUI) ; Create child windo inside the main GUI $MainMSG = GUIGetMsg(1) While 1 SettingsGUI_MonitorChanges() ; If some data on the inputs in the SettingsGUI was changed then do something... Switch $MainMSG[1] Case $MainGUI ; Do stuff about the main gui Case $SettingsGUI #NameSpace SettingsGUI ProcessMSG() DoSomeThingElse() #NameSpaceEnd Case $OtherGUI #NameSpace OtherGUI ProcessMSG() DoSomeThingElse() #NameSpaceEnd EndSwitch WEnd EndFunc #NameSpace SettingsGUI #cs ; Autoit will see every function and *global* variable in this name space as it was start with "SettingsGUI_" So this function call for example "Settings_GUI(*)" is still valid call. ** using this NameSpace method is like writing every function and global variable with the prefix that is the name space. in this case the prefix is "SettingsGUI_" #ce Func Create($hPerentGUI) ; Create and return the child gui EndFunc Func MonitorChanges() EndFunc Func ProcessMSG() EndFunc Func SettingsGUI_DrawSettings() ; Draw settings of the controls.. EndFunc Func DoSomeThingElse() EndFunc #NameSpaceEnd #NameSpace OtherGUI #cs #ce Global $SomeVar ; This will be in fact $OtherGUI_SomeVar Func ProcessMSG() ; This will be in fact OtherGUI_ProcessMSG() Local $SomeVar2 ; This is will NOT be $OtherGUI_SomeVar2. it is not Global ! EndFunc Func DoSomeThingElse() ; This will be in fact $OtherGUI_DoSomeThingElse EndFunc #NameSpaceEnd Edited April 12, 2017 by Guest 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