Jump to content

GUICtrlTab UDF


 Share

Recommended Posts

i'm trying to use the GUICtrlTab UDF but i can't figure out how to add data to the tabs.

i know with the built in guictrlcreatetabitem() all i have to do is add the data after that but it dosn't work that way with the UDF or i'm just doing something stupid

what my over all goal is, is to take advantage of the $TCS_MULTILINE style in the UDF.

i can't seem to find an answer to this anywhere in the autoit help and i did a few searches here that didn't turn up what i wanted either.

Thanks for your help

Link to comment
Share on other sites

  • Moderators

tlman12,

Unlike the built-in GUICtrlCreateTab, you have to hide/show the controls yourself when you use the GUICtrlTab UDF. ;)

Here is a short example - note how the 3 buttons are created in the same place and we have to determine which should be shown depending on the active tab:

#include <GuiConstantsEx.au3>
#include <GuiTab.au3>

; Create GUI
$hGUI = GUICreate("Test", 400, 300)
$hTab = _GUICtrlTab_Create($hGUI, 2, 2, 396, 296)
GUISetState()

; Add tabs
_GUICtrlTab_InsertItem($hTab, 0, "Tab 1")
_GUICtrlTab_InsertItem($hTab, 1, "Tab 2")
_GUICtrlTab_InsertItem($hTab, 2, "Tab 3")

; Add controls and only show those on the active tab
$hButton_1 = GUICtrlCreateButton("Test 1", 10, 30, 80, 30)
$hButton_2 = GUICtrlCreateButton("Test 2", 10, 30, 80, 30)
GUICtrlSetState(-1, $GUI_HIDE)
$hButton_3 = GUICtrlCreateButton("Test 3", 10, 30, 80, 30)
GUICtrlSetState(-1, $GUI_HIDE)

; This is the current active tab
$iLastTab = 0

; Loop until user exits
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton_1
            MsgBox(0, "Button", "You pressed the button on Tab 1")
        Case $hButton_2
            MsgBox(0, "Button", "You pressed the button on Tab 2")
        Case $hButton_3
            MsgBox(0, "Button", "You pressed the button on Tab 3")
    EndSwitch

    ; Check which tab is active
    $iCurrTab = _GUICtrlTab_GetCurFocus($hTab)
    ; If the tab has changed
    If $iCurrTab <> $iLastTab Then
        ; Store the value for future comparisons
        $iLastTab = $iCurrTab
        ; Show/Hide controls as required
        Switch $iCurrTab
            Case 0
                GUICtrlSetState($hButton_1, $GUI_SHOW)
                GUICtrlSetState($hButton_2, $GUI_HIDE)
                GUICtrlSetState($hButton_3, $GUI_HIDE)
            Case 1
                GUICtrlSetState($hButton_1, $GUI_HIDE)
                GUICtrlSetState($hButton_2, $GUI_SHOW)
                GUICtrlSetState($hButton_3, $GUI_HIDE)
            Case 2
                GUICtrlSetState($hButton_1, $GUI_HIDE)
                GUICtrlSetState($hButton_2, $GUI_HIDE)
                GUICtrlSetState($hButton_3, $GUI_SHOW)
        EndSwitch
    EndIf

WEnd

Please ask if anything is unclear. :blink:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

tlman12,

Unlike the built-in GUICtrlCreateTab, you have to hide/show the controls yourself when you use the GUICtrlTab UDF. ;)

Here is a short example - note how the 3 buttons are created in the same place and we have to determine which should be shown depending on the active tab:

#include <GuiConstantsEx.au3>
#include <GuiTab.au3>

; Create GUI
$hGUI = GUICreate("Test", 400, 300)
$hTab = _GUICtrlTab_Create($hGUI, 2, 2, 396, 296)
GUISetState()

; Add tabs
_GUICtrlTab_InsertItem($hTab, 0, "Tab 1")
_GUICtrlTab_InsertItem($hTab, 1, "Tab 2")
_GUICtrlTab_InsertItem($hTab, 2, "Tab 3")

; Add controls and only show those on the active tab
$hButton_1 = GUICtrlCreateButton("Test 1", 10, 30, 80, 30)
$hButton_2 = GUICtrlCreateButton("Test 2", 10, 30, 80, 30)
GUICtrlSetState(-1, $GUI_HIDE)
$hButton_3 = GUICtrlCreateButton("Test 3", 10, 30, 80, 30)
GUICtrlSetState(-1, $GUI_HIDE)

; This is the current active tab
$iLastTab = 0

; Loop until user exits
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton_1
            MsgBox(0, "Button", "You pressed the button on Tab 1")
        Case $hButton_2
            MsgBox(0, "Button", "You pressed the button on Tab 2")
        Case $hButton_3
            MsgBox(0, "Button", "You pressed the button on Tab 3")
    EndSwitch

    ; Check which tab is active
    $iCurrTab = _GUICtrlTab_GetCurFocus($hTab)
    ; If the tab has changed
    If $iCurrTab <> $iLastTab Then
        ; Store the value for future comparisons
        $iLastTab = $iCurrTab
        ; Show/Hide controls as required
        Switch $iCurrTab
            Case 0
                GUICtrlSetState($hButton_1, $GUI_SHOW)
                GUICtrlSetState($hButton_2, $GUI_HIDE)
                GUICtrlSetState($hButton_3, $GUI_HIDE)
            Case 1
                GUICtrlSetState($hButton_1, $GUI_HIDE)
                GUICtrlSetState($hButton_2, $GUI_SHOW)
                GUICtrlSetState($hButton_3, $GUI_HIDE)
            Case 2
                GUICtrlSetState($hButton_1, $GUI_HIDE)
                GUICtrlSetState($hButton_2, $GUI_HIDE)
                GUICtrlSetState($hButton_3, $GUI_SHOW)
        EndSwitch
    EndIf

WEnd

Please ask if anything is unclear. :blink:

M23

that seems like a big pain in the but if you have a lot of controls (which i do) theres nothing easier?

Link to comment
Share on other sites

  • Moderators

tlman12 ,

theres nothing easier?

If you want to use the UDF, you must accept the limitations of the UDF as well. :blink:

But why do you want to use the UDF anyway? The built-in GUICtrlCreateTab function can use the $TCS_MULTILINE style and AutoIt looks after all the controls for you:

#include <GUIConstantsEx.au3>
#include <TabConstants.au3>

$hGUI = GUICreate("Tab Row Example", 500, 500)

$hTab = GUICtrlCreateTab(10, 10, 480, 480, BitOR($GUI_SS_DEFAULT_TAB, $TCS_MULTILINE, $TCS_RIGHTJUSTIFY))
; Create tabitems
For $i = 1 To 15
    GUICtrlCreateTabItem($i)
    GUICtrlCreateButton("Button " & $i, 20, 100, 80, 30)
Next
; Close Tab definiton
GUICtrlCreateTabItem("")

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Your choice!

M23

P.S. And when you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. ;)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...