@
Entropy: Maybe you could use
Gui, 1: New if you wanted to set the Gui's name in such a way as to avoid the need for taking care of where non-Gui threads will need the default Gui to be set correctly.
I agree with you, If there is just a single Gui in your script, it's easier to not use
Gui, New at all.
If there is a single Gui in your script, and you want to use
Gui, New, then its easiest to name your Gui
1: (well, that's technically numbering, I guess)
I often use lines similar to this:
Gui, 1: New, +AlwaysOnTop +Owner, %AppName% for the sake of setting the title together with setting the Gui options.
Entropy wrote:You said, "GuiControl does not work on unnumbered and unnamed Gui's without the default Gui being set correctly."
But in my case, wasn't my GUI named "GoW_Helper"?
Right, but ....
GuiControl does not work on
any Gui without the default Gui being set correctly, other than ...
GuiControl only works on the Gui that is named/numbered
1:, without the default Gui being set correctly.
Or, with the default Gui being set correctly GuiControl will work correctly.
Or, still one more freedom: You don't have to set the default Gui if you don't want to, (maybe your next 5 lines of code will concern a different Gui anyway)
you can choose to tell each GuiControl which Gui to target, see
garry's example. (@garry: don't you have to also tell GuiControlGet which Gui to target? I'm sure it is needed)
Try this:
Code: Select all
n=1 ; this helps to visualize later
Gui, GoW_Helper: New,, GoW Helper
Gui, Font, s14
Gui, Add, ListView, vMovesLV r10 w750 Count10 Grid -Multi , Score|Move|Xtra Turn
LV_ModifyCol(2,60)
Gui, Add, Text, vStatusBox w750 r4, Initializing GUI ; <<<<<< 4 rows for sake of visualizing
Gui, Show, X700 y400 NoActivate
return
GoW_HelperGuiclose:
exitapp
F9:: ; visualizer
updateStatusBox(n++)
return
updateStatusBox(newText)
{
GuiControlGet, oldText, GoW_Helper:, StatusBox
GuiControl, GoW_Helper:, StatusBox, % newText "`n" oldText
}
I hope that helps.
Note: I believe that
GuiControlGet needs to be told the "GuiNameOrNumber" inside the second parameter, since it is a command with
first parameter = OutputVar.
Other GuiXXX commands expect the "GuiNameOrNumber" inside the first parameter.
I don't actually know for sure, I always play around with this and use examples that can show me what's going on.
PS: I have changed the variable name for the "StatusBox" to StatusBox, to match with the function's name.
PS2: If you're still uncertain about this, don't hesitate to ask again, I'm not sure if I used the right words or if I constructed my sentences correctly, but I tried.