Jump to content
jasty

Resizing a multiline tab control

Recommended Posts

I have a tab control as the main content of my tool and am struggling a bit with how to handle the multi lines.   Controls inside the tab control are not shifting when the number of lines is changed due to resizing and when there are 3 or more header rows they are overlapping with the tabs.   

First off is there any automatic way to shift the controls?

I am trying the manual route by using _GUICtrlTab_GetDisplayRect in a WM_MOVE handler so that I know how far the controls have to be shifted but there doesnt seem to be a good way to move the controls.  When I use ControlMove it conflicts with AutoIt's automatic resizing since I am using GUICtrlSetResizing on all of the controls and if I use GUICtrlSetPos through AutoIt it causes AutoIt to forget the initial layout position while resizing causing controls to shift slightly and the errors accumulate rapidly misaligning everything.  

Am I missing something easy?   Is there any layout engine in autoit that can handle multi line tabs gracefully?

Share this post


Link to post
Share on other sites
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <GuiTab.au3>
#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>

global $CLIENT_RECT
Func Example()
    global $hGUI = GUICreate("TABs", 310, 428 , Default, Default, BitOr($WS_SIZEBOX,$WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SYSMENU ))
    global $hTabs = GUICtrlCreateTab(10, 35, 292, 360, $TCS_MULTILINE)
    GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
    for $i = 0 to 10
        GUICtrlCreateTabItem("TAB"&$i)
        $y = 75
        for $j = 0 to 10
            GUICtrlCreateButton("Button"&$i&"-"&$j, 20 + Mod($j, 4)*70, $y, 60, 30)
            GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKHEIGHT)
            if Mod($j, 4) == 3 Then
                $y += 40
            EndIf
        next

    Next
    GUICtrlCreateTabItem("")
    global $lastControl = GUICtrlCreateLabel("Resizing this window back and forth a few times", 10, 15)
    GUICtrlSetResizing(-1, $GUI_DOCKTOP + $GUI_DOCKHEIGHT)
    $CLIENT_RECT = _GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($hTabs))
    GUISetState(@SW_SHOW, $hGUI)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

  Exit
EndFunc   ;==>Example


GUIRegisterMsg($WM_SIZE, 'WM_SIZE')

Func WM_SIZE($hWnd, $iMsg, $iWParam, $iLParam)
    If $hwnd == $hGUI then
        $rect = _GUICtrlTab_GetDisplayRect(GUICtrlGetHandle($hTabs))
        $tabHeightAdjust = $rect[1] - $CLIENT_RECT[1]
        if $tabHeightAdjust <> 0 Then
            for $i = ($hTabs +1) to ($lastControl -1)
                $pos = ControlGetPos($hGUI, "", GUICtrlGetHandle($i))
                GuiCtrlSetPos($i, Default, $pos[1] + $tabHeightAdjust)
            Next
            $CLIENT_RECT = $rect
        Endif
    EndIf
    return $GUI_RUNDEFMSG
endfunc

Example()

 

Edited by jasty

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...