The following is an addon that will layout all the controls for a Tab control.
Code requires the TableLayout function linked above as well as List functions included here:
List.ahk
A simple example is provided in the code.
Code:
#Include List.ahk
#Include TableLayout.ahk
/* Usage:
* Layout controls in a Tab control with TableLayout
*
* Parameters:
* ctrls: A list of all controls, with the Tab control being the first in the list.
* ctrlCounts: Comma delimited list of the number of tabs in each control.
* rules: Comma delimited list of rules. The first rule in the list will be the default for all tabs.
* The second rule corresponds to the first tab.
* Only provide one set of rules (the default) if all tabs are to use the same rules.
* spacing, marginX, marginY, w, h: See TableLayout
*
* Example:
* Gui, +LastFound
* margin = 3
* Gui, Margin, %margin%, %margin%
* Gui, Add, Tab, , One|Two
* Gui, Tab, 1
* Gui, Add, Edit
* Gui, Add, Edit
* Gui, Add, Edit
* Gui, Add, Edit
* Gui, Add, Edit
* Gui, Tab, 2
* Gui, Add, Text, , One
* Gui, Add, Text, , Two
* Gui, Add, Text, , Three
* Gui, Add, Edit
* Gui, Add, Edit
* Gui, Add, Edit
* WinGet, ctrls, ControlList
* TabTableLayout(ctrls, "5,6", ",w100 h1 r2|w100_w100_w1 c2,a1|a1|a1_w200 c2|w100_w1 c3", 5, 5, 5, w, h)
* w += margin * 2
* h += margin * 2
* Gui, Show, w%w% h%h%
*/
TabTableLayout(ByRef ctrls, ctrlCounts, rules, spacing, marginX, marginY, ByRef w = "", ByRef h = "") {
tab := ListGet(ctrls, 0, "`n")
index := 1
rDefault := ListGet(rules, 0)
rSize := ListSize(rules)
w := h := 0
GuiControlGet, tabPos, Pos, %tab%
Loop, Parse, ctrlCounts, `,
{
j := index
tabCtrls := ListSegment(ctrls, j, index += A_LoopField, "`n")
tabRules := A_Index < rSize ? ListGet(rules, A_Index) : ""
tabW := tabH := ""
TableLayout(tabCtrls, tabRules ? tabRules : rDefault, spacing, marginX, marginY, x, y, tabW, tabH)
if (tabW > w)
w := tabW
if (tabH > h)
h := tabH
}
x -= tabPosX
y -= tabPosY
w += x
h += y
GuiControl, Move, %tab%, w%w% h%h%
}