submeg wrote: ↑28 Jan 2024, 00:48
I have found that splitting out moving to each tab into separate functions is useful, as I can perform different actions when switching between tabs.
Not sure if this is what you are going for. If you want a specific function to run when switching tabs, you could detect when a tab is changed and then do certain actions based on what tab was activated and/or deactivated. You wouldn't need a button on every tab and separate functions to switch tabs, but instead use if-statements based on what tab it is.
Code: Select all
#Requires AutoHotkey v2+
#SingleInstance Force
SSGui := Gui()
Tab := SSGui.Add("Tab3","vTabSelect h470 w480",
tabList := ["System","Symptoms","Tab3","Tab4","Tab5","Tab6","Tab7","Tab8"])
Tab.OnEvent("Change", TabChanged)
SSGui.Show("W500 H510")
TabChanged(GuiCtrlObj, Info) {
static PrevTab := 1
NewTab := GuiCtrlObj.Value
MsgBox "Switched from tab " PrevTab " (" tabList[PrevTab] ") to " NewTab " (" tabList[NewTab] ")"
PrevTab := NewTab
}
If you want to have a next button, here is one idea:
Code: Select all
#Requires AutoHotkey v2+
#SingleInstance Force
SSGui := Gui()
Tab := SSGui.Add("Tab3","vTabSelect h470 w480",
tabList := ["System","Symptoms","Tab3","Tab4","Tab5","Tab6","Tab7","Tab8"])
for i, tabName in tabList {
Tab.UseTab(i)
SSGui.Add("Button", "default x380 y440 w100", "Next").OnEvent("Click", NextTab)
}
SSGui.Show("W500 H510")
NextTab(GuiCtrlObj, Info) {
thisTab := Tab.Value
nextTab := (thisTab = tabList.Length) ? 1 : ++thisTab
Tab.Choose(nextTab)
}