[v2] TabControl children

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

[v2] TabControl children

16 Mar 2019, 21:02

I am using a Tab3 control and am adding a single Edit control to each tab. Within my app, there are workflows I have coded which will also Delete tabs from this Tab control. It could be any tab.

Let's say I have three tabs. If I delete tab 2, then the Edit which was associated with Tab #2 is now associated with what used to be Tab #3. I'm not sure how I can fix this.

I've tried using a single Edit control and positioning it properly within the tabs inner region but this seems to cause issue with focusing the control.
And on those same lines, I don't see a way to move a control from one tab to another.

Anyone have any bright ideas?
Kobaltauge
Posts: 264
Joined: 09 Mar 2019, 01:52
Location: Germany
Contact:

Re: [v2] TabControl children

17 Mar 2019, 05:48

I don't know anything about GUI programming in AHK. It just an idea.
Is there a possibility to "hide" the tabs instead to delete them? So the association would remain to the tab.
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: [v2] TabControl children

17 Mar 2019, 10:01

Here's a simple example that demonstrates one of my problems.

Select Tab #2 and then click the button to remove that tab. If you then select the Tab with the text of 3, you will see that its content now has the "Text 2" control.

Code: Select all

main := GuiCreate()

btn := main.addButton("", "Remove Tab")
btn.OnEvent("Click", (ctrl) => removeTab(ctrl.gui))

tabs := main.addTab3("w400 h400 vTabs", "1|2|3")

main.addText("", "Text 1")

tabs.useTab(2)
main.addText("", "Text 2")

tabs.useTab(3)
main.addText("", "Text 3")

tabs.useTab()

main.show()
Return

removeTab(gui) {
    gui.control["Tabs"].Delete(gui.control["Tabs"].value)
}
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: [v2] TabControl children

17 Mar 2019, 11:59

I haven't used v2 yet but this is what the doc for v1 says.


Tab controls: In addition to the behavior described in the paragraph above, a tab's sub-controls stay associated with their original tab number; that is, they are never associated with their tab's actual display-name. For this reason, renaming or removing a tab will not change the tab number to which the sub-controls belong. For example, if there are three tabs "Red|Green|Blue" and the second tab is removed by means of GuiControl,, MyTab, |Red|Blue, the sub-controls originally associated with Green will now be associated with Blue. Because of this behavior, only tabs at the end should generally be removed. Tabs that are removed in this way can be added back later, at which time they will reclaim their original set of controls.
Have you considered making your own tabs?
Kobaltauge
Posts: 264
Joined: 09 Mar 2019, 01:52
Location: Germany
Contact:

Re: [v2] TabControl children

17 Mar 2019, 12:38

I would like to help. But GuiCreate() is a "nonexistent function" on my PC. I can't run your example.
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: [v2] TabControl children

17 Mar 2019, 14:33

@Hellbent, I’m using several other Tab controls in the GUI and I’d like to maintain the look and feel of all tab controls.

With very preliminary testing, it seems if I use a Tab2 control that I can place a single edit control over the display area and then maintain the content for each Tab in memory. It could end up being more work than I’d like though.
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: [v2] TabControl children

17 Mar 2019, 14:48

What about putting the tabs on a child gui embedded in your main gui and then just destroying and recreating the tab child when tabs are removed?
Kobaltauge
Posts: 264
Joined: 09 Mar 2019, 01:52
Location: Germany
Contact:

Re: [v2] TabControl children

17 Mar 2019, 14:51

Kobaltauge wrote:
17 Mar 2019, 12:38
I would like to help. But GuiCreate() is a "nonexistent function" on my PC. I can't run your example.
I'm such a idi*t. Sorry. After a while I realised the [v2] in your post.
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: [v2] TabControl children

17 Mar 2019, 16:12

Hellbent wrote:
17 Mar 2019, 14:48
What about putting the tabs on a child gui embedded in your main gui and then just destroying and recreating the tab child when tabs are removed?
That be more work than just maintaining the contents of an edit I think

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: arcylix, Descolada and 26 guests