Tab control can't change background color after creation
Issue #10
closed
No description provided.
Comments (8)
-
-
reporter Please do. Keysharp only supports V2.
That script is overkill. Just a simple tab control that is set to some custom color, then a button click to change it to a different color.
-
Okay, I’ll try that, but to paraphrase Mark Twain, if I’d had more time I’d have written something shorter. That v1 code was snipped from an ancient forum post.
Effort so far:
TabColors_Tab1 := "FF0000" TabColors_Tab2 := "00FF00" TabColors_Tab3 := "0000FF" MyGui := Gui("+AlwaysOnTop +OwnDialogs -MinimizeBox") MyTab := MyGui.Add("Tab3", "w100 x3 y+2 h100 w113 AltSubmit", ["First","Second","Third"]) MyTab.OnEvent("Change", TabFunc) MyGui.Show() return !Esc::ExitApp TabFunc(*) { if (MyTab.Value == 1) { MyGui.BackColor := TabColors_Tab1 } if (MyTab.Value == 2) { MyGui.BackColor := TabColors_Tab2 } if (MyTab.Value == 3) { MyGui.BackColor := TabColors_Tab3 } }
That’s what I had when I opened the page just now. I’ll need to work on something shorter.
-
Afraid it needs two tabs to make sense. If I don’t get a “Change” event nothing will happen, and if there’s only one tab it won’t change.
NewColor := "FF0000" MyGui := Gui("+AlwaysOnTop +OwnDialogs -MinimizeBox") MyTab := MyGui.Add("Tab3", "w100 x3 y+2 h100 w113 AltSubmit", ["Test", "Retest"]) MyTab.OnEvent("Change", TabFunc) MyGui.Show() return !Esc::ExitApp TabFunc(*) { MyGui.BackColor := NewColor }
-
reporter Update your source and verify this works:
TabColors_Tab1 := "FF0000" TabColors_Tab2 := "00FF00" TabColors_Tab3 := "0000FF" MyGui := Gui() MyTab := MyGui.Add("Tab3", "w300 h300", ["First","Second","Third"]) MyTab.OnEvent("Change", "TabFunc") MyGui.Show() TabFunc() { global if (MyTab.Value == 1) { MyGui.BackColor := TabColors_Tab1 MyTab.Opt("Background" TabColors_Tab1) } if (MyTab.Value == 2) { MyGui.BackColor := TabColors_Tab2 MyTab.Opt("Background" TabColors_Tab2) } if (MyTab.Value == 3) { MyGui.BackColor := TabColors_Tab3 MyTab.Opt("Background" TabColors_Tab3) } }
-
Tested, resolved.
-
reporter - changed status to resolved
-
reporter - changed status to closed
- Log in to comment
AHK 1 script (I’ll try to do a v2 version, might take a bit):