You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1 Tab Example on Thu Apr 28, 2011 11:31 pm

des

avatar
Achiever
Loading
Examples of tabs.

This was really old work I found.

Code:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TabConstants.au3>
#include <GuiListView.au3>
#include <GuiTab.au3>

Opt("GUIResizeMode", $GUI_DOCKBORDERS)

; When window is resized, run this function
GUIRegisterMsg($WM_SIZE, "MY_WM_SIZE")

Global $iGUIWidth = 800, $iGUIHeight = 500, $fResized = False

$MainGUI = GUICreate("Tab Row Example", $iGUIWidth, $iGUIHeight, Default, Default, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
$TAB = GUICtrlCreateTab(1, 1, $iGUIWidth - 2, $iGUIHeight - 50, BitOR($GUI_SS_DEFAULT_TAB, $TCS_MULTILINE, $TCS_RIGHTJUSTIFY))

; Set number of TabItems
Global $iTabNumber = 15

; Create array holding dummy tabitem titles
Global $aTitles[$iTabNumber + 1]
For $i = 1 To $iTabNumber
    $aTitles[$i] = ""
    For $j = 1 To Random(4, 10, 1)
        $aTitles[$i] &= String($i) & " "
    Next
Next
 
; Determine initial TabTop value
$iTabTop = Tab_Sizer($iTabNumber, $aTitles)

; Create array to hold ListView handles
Global $aListView[$iTabNumber + 1] = [$iTabNumber]

; Create tabitems
For $i = 1 To $iTabNumber

    GUICtrlCreateTabItem($aTitles[$i])
    $aListView[$i] = GUICtrlCreateListView("Filelist", 10, $iTabTop, $iGUIWidth - 22, $iGUIHeight - $iTabTop - 50, -1, $LVS_EX_CHECKBOXES)
        _GUICtrlListView_SetColumnWidth($aListView[$i], 0, $LVSCW_AUTOSIZE_USEHEADER)
        _GUICtrlListView_SetBkColor($aListView[$i], 0xFF0000) ; Just to show the size
        GUICtrlSetResizing($aListView[$i], BitOR($GUI_DOCKBORDERS, $GUI_DOCKLEFT))

; Fill ListView with items
    For $j = 1 To 25
        GUICtrlCreateListViewItem("Item " & $j & " - ListView " & $i & "    Computer Talks", $aListView[$i])
    Next

Next

; Close Tab definiton
GUICtrlCreateTabItem("")

; Create dummy button
$hButton = GUICtrlCreateButton("Button", 10, $iGUIHeight - 40, 120, 30)
GUICtrlSetResizing(-1, BitOR($GUI_DOCKWIDTH, $GUI_DOCKHEIGHT, $GUI_DOCKBOTTOM))

GUISetState(@SW_SHOW)

While 1
 
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
        ; dummy
    EndSwitch
 
; Look for resize message
    If $fResized Then

    ; Determine new TabTop value
        $iTabTop = Tab_Sizer($iTabNumber, $aTitles)
    ; Reposition all Listviews to fit new Tab dimensions
        For $i = 1 To $aListView[0]
            GUICtrlSetPos($aListView[$i], 10, $iTabTop, $iGUIWidth - 22, $iGUIHeight - $iTabTop - 50)
            _GUICtrlListView_SetColumnWidth($aListView[$i], 0, $LVSCW_AUTOSIZE_USEHEADER)
        Next
    ; Reset flag
        $fResized = False
    EndIf

WEnd

Func Tab_Sizer($iTabTotal, $aTabTitles)
 
; Create test GUI
    $TestGUI = GUICreate("", $iGUIWidth, 500)
; Create test Tab
    $TestTAB = GUICtrlCreateTab(1, 1, $iGUIWidth - 2, 500, BitOR($GUI_SS_DEFAULT_TAB, $TCS_MULTILINE, $TCS_RIGHTJUSTIFY))
; Create correct number of TabItems
    For $i = 1 To $iTabTotal
        GUICtrlCreateTabItem($aTabTitles[$i])
    Next
; Measure the client area of the Tab
    $aPos = _GUICtrlTab_GetDisplayRect(ControlGetHandle($TestGUI, "", $TestTAB))
; Delete test GUI
    GUIDelete($TestGUI)
; Return new TabTop value
    Return $aPos[1]
 
EndFunc
 
Func MY_WM_SIZE($hWnd, $Msg, $wParam, $lParam)
 
    $iGUIWidth = BitAND($lParam, 0xFFFF)
    $iGUIHeight = BitShift($lParam, 16)
; Set flag
    $fResized = True
     
    Return $GUI_RUNDEFMSG
 
EndFunc  ;==>MY_WM_SIZE

2 Re: Tab Example on Fri Apr 29, 2011 12:52 am

Guest


Guest
Loading
tabs foe what?

3 Re: Tab Example on Fri Apr 29, 2011 1:38 am

des

avatar
Achiever
Loading
For AutoIt, can't you see where I posted this?

4 Re: Tab Example on Fri Apr 29, 2011 1:48 am

Guest


Guest
Loading
Don't pay attention.

Sponsored content


Loading

View previous topic View next topic Back to top  Message [Page 1 of 1]

Related topics

Permissions in this forum:
You cannot reply to topics in this forum