Sign in to follow this  
Followers 0
AlmarM

_Create_Tab()

12 posts in this topic

#1 ·  Posted (edited)

Hello,

I was writing a script and I wasted my time by writing GUICtrlCreateTab() and GUICtrlCreateTabItem() all the time.

So I wrote _Create_Tab()

I know its simple, but I tought I shared it with you guys :)

; #FUNCTION# ===========================================================================
; Name...........: _Create_Tab()
; Description ...: Uses the GUICtrlCreateTab() and GUICtrlCreateTabItem() in one
; Syntax.........: _CreateTab($left, $top, $width, height, [$style, [$exstyle]])
; Parameters ....: -
; Return values .: -
; Author ........: Almar Mulder (AlmarM)
; Modified.......: -
; Remarks .......: -
; Related .......: GUICtrlCreateTab(), GUICtrlCreateTabItem()
; Link ..........: http://www.autoitscript.com/forum/index.php?showtopic=80919
; Example .......: Yes (_Create_Tab(10, 10, 500, 500, "Example Tab", $TCS_FIXEDWIDTH, $TCS_EX_FLATSEPARATORS))
; #FUNCTION# ===========================================================================
Func _Create_Tab($left, $top, $width, $height, $name, $style = "", $exstyle = "")
    GUICtrlCreateTab($left, $top, $width, $height, $style, $exstyle)
    GUICtrlCreateTabItem($name)
EndFunc

Its GUICtrlCreateTab() and GUICtrlCreateTabItem() in ONE!

AlmarM

EDIT: Added the cool #FUNCTION# thing >_<

Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites



Hello,

I was writing a script and I wasted my time by writing GUICtrlCreateTab() and GUICtrlCreateTabItem() all the time.

So I wrote _Create_Tab()

I know its simple, but I tought I shared it with you guys :)

; #FUNCTION# ===========================================================================
; Name...........: _Create_Tab()
; Description ...: Uses the GUICtrlCreateTab() and GUICtrlCreateTabItem() in one
; Syntax.........: _CreateTab($left, $top, $width, height, [$style, [$exstyle]])
; Parameters ....: -
; Return values .: -
; Author ........: Almar Mulder (AlmarM)
; Modified.......: -
; Remarks .......: -
; Related .......: GUICtrlCreateTab(), GUICtrlCreateTabItem()
; Link ..........: http://www.autoitscript.com/forum/index.php?showtopic=80919
; Example .......: Yes (_Create_Tab(10, 10, 500, 500, "Example Tab", $TCS_FIXEDWIDTH, $TCS_EX_FLATSEPARATORS))
; #FUNCTION# ===========================================================================
Func _Create_Tab($left, $top, $width, $height, $name, $style = "", $exstyle = "")
    GUICtrlCreateTab($left, $top, $width, $height, $style, $exstyle)
    GUICtrlCreateTabItem($name)
EndFunc

Its GUICtrlCreateTab() and GUICtrlCreateTabItem() in ONE!

AlmarM

EDIT: Added the cool #FUNCTION# thing >_<

It is maybe a little too simple since if you want more than one tab it hasn't really helped much. If you made it a bit more versatile so it could create all the tabs you needed then it would be more useful.

_Create_tab(80,100,250,200,"onions|tomatoes|figs")

Func _Create_Tab($left, $top, $width, $height, $tabnames, $style = "", $exstyle = "")
    Local $TabItems = StringSplit($tabnames, "|")
    GUICtrlCreateTab($left, $top, $width, $height, $style, $exstyle)
    For $n = 1 To $TabItems[0]
        GUICtrlCreateTabItem($TabItems[$n])
    Next
EndFunc  ;==>_Create_Tab

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

It is maybe a little too simple since if you want more than one tab it hasn't really helped much. If you made it a bit more versatile so it could create all the tabs you needed then it would be more useful.

_Create_tab(80,100,250,200,"onions|tomatoes|figs")

Func _Create_Tab($left, $top, $width, $height, $tabnames, $style = "", $exstyle = "")
    Local $TabItems = StringSplit($tabnames, "|")
    GUICtrlCreateTab($left, $top, $width, $height, $style, $exstyle)
    For $n = 1 To $TabItems[0]
        GUICtrlCreateTabItem($TabItems[$n])
    Next
EndFunc ;==>_Create_Tab
Heya!

Nice one, didnt tought about that one!

AlmarM


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

Also that function should return $TabItems[] array

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Also that function should return $TabItems[] array

8)

Um, that's a good point. Maybe something like this

$tab1 = _Create_tab(80,100,250,200,"onions|tomatoes|figs")


;Creates a tab with tabitems as the '|' separated list in $tabnames 
;returns an array where 
;                element [0] = tab ID
;                element [1] = number of tabitems
;                element [2] = tabitem1 
;                element [3] = tabitem2 ID etc
Func _Create_Tab($left, $top, $width, $height, $tabnames, $style = "", $exstyle = "")

    Local $TabItems = StringSplit($tabnames, "|")
    Local $ttab[ubound($TabItems) + 1]

    $ttab[0] = GUICtrlCreateTab($left, $top, $width, $height, $style, $exstyle)
    $ttab[1] = $TabItems[0]
    For $n = 1 To $TabItems[0]
        $ttab[$n + 1] = GUICtrlCreateTabItem($TabItems[$n])
    Next
    Return $ttab
EndFunc ;==>_Create_Tab

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hey,

I've tried the same thing, but it isnt working all :)

Its just for fun ^^

Func _Create_Tabs($left, $top, $width, $height, $tabs, $style = "", $exstyle = "")
    Local $TabItems = StringSplit($tabs, "|")
    Local $Tab[UBound($TabItems) +1]
    $Tab[0] = GUICtrlCreateTab($left, $top, $width, $height, $style, $exstyle)
    $Tab[1] = $TabItems[0]
    For $x = 1 To $TabItems[0]
        $Tab[$x + 1] = GUICtrlCreateTabItem([$x])
    Next
    Return $Tab
EndFunc ;==> _Create_Tab()

Func _Create_Listviews($text, $items, $listviewID, $left, $top, $width, $height, $style = "", $exstyle = "")
    Local $ListItems = StringSplit($items, "|")
    Local $List[UBound($ListItems) +1]
    $List[0] = GUICtrlCreateListView($text, $left, $top, $width, $height, $style, $exstyle)
    $List[1] = $ListItems[0]
    For $x = 1 To $ListItems[0]
        $List[$x + 1] = GUICtrlCreateListViewItem([$x], $listviewID)
    Next
    Return $List
EndFunc ;==> _Create_Listviews()

Func _Create_Menus($submenutext, $itemtext, $menuid, $menuentry, $radio = 0)
    Local $MenuItems = StringSplit($itemtext, "|")
    Local $Menu[UBound($MenuItems) +1]
    $Menu[0] = GUICtrlCreateMenu($submenutext, $menuid, $menuentry)
    $Menu[1] = $MenuItems[0]
    For $x = 1 To $MenuItems[0]
        $Menu[$x + 1] = GUICtrlCreateMenuItem($itemtext, $menuid, $menuentry, $radio)
    Next
    Return $Menu
EndFunc ;==> _Create_Menus()

Func _Create_TreeViews($text, $treeviewID, $left, $top, $width, $height, $style = "", $exstyle = "")
    Local $TreeItems = StringSplit($text, "|")
    Local $Tree[UBound($TreeItems) +1]
    $Tree[0] = GUICtrlCreateTreeView($left, $top, $width, $height, $style, $exstyle)
    $Tree[1] = $TreeItems[0]
    For $x = 1 To $TreeItems[0]
        $Tree[$x + 1] = GUICtrlCreateTreeViewItem($text, $treeviewID)
    Next
    Return $Tree
EndFunc ;==> _Create_TreeViews()

AlmarM

Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

Hmm, I was thinking.

If you use this

Func _Create_Tab($left, $top, $width, $height, $tabnames, $style = "", $exstyle = "")

    Local $TabItems = StringSplit($tabnames, "|")
    Local $ttab[ubound($TabItems) + 1]

    $ttab[0] = GUICtrlCreateTab($left, $top, $width, $height, $style, $exstyle)
    $ttab[1] = $TabItems[0]
    For $n = 1 To $TabItems[0]
        $ttab[$n + 1] = GUICtrlCreateTabItem($TabItems[$n])
    Next
    Return $ttab
EndFunc ;==>_Create_Tab

Can you still made a button on for example tab 2 if there are like 5 tabs.

AlmarM


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

Hmm, I was thinking.

If you use this

Func _Create_Tab($left, $top, $width, $height, $tabnames, $style = "", $exstyle = "")

    Local $TabItems = StringSplit($tabnames, "|")
    Local $ttab[ubound($TabItems) + 1]

    $ttab[0] = GUICtrlCreateTab($left, $top, $width, $height, $style, $exstyle)
    $ttab[1] = $TabItems[0]
    For $n = 1 To $TabItems[0]
        $ttab[$n + 1] = GUICtrlCreateTabItem($TabItems[$n])
    Next
    Return $ttab
EndFunc ;==>_Create_Tab

Can you still made a button on for example tab 2 if there are like 5 tabs.

AlmarM

Er, no. At least I don't see how at the moment. :/

I also left out GUICtrlCreateTabItem("") after the tabs had been created.

Perhaps the function should be allowed to slip slowly and quietly away.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Er, no. At least I don't see how at the moment. :/

I also left out GUICtrlCreateTabItem("") after the tabs had been created.

Perhaps the function should be allowed to slip slowly and quietly away.

You could reuse the $TabItems[] array with GUICtrlSetState() switch which should allow you to add buttons and other things at whichever tab you want. GuiCtrlSetState($tabitems[..], ...)

Think this would work..


My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites

But the _Create_Tabs() func will create as many tabs as you want. But you could only make buttons or inputs or what ever on the last tab I think. You can't create stuff on for example the 2nd one.

I think mine

Func _Create_Tab($left, $top, $width, $height, $name, $style = "", $exstyle = "")
    GUICtrlCreateTab($left, $top, $width, $height, $style, $exstyle)
    GUICtrlCreateTabItem($name)
EndFunc

Is just more usefull.

Just my toughts...

AlmarM


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

But the _Create_Tabs() func will create as many tabs as you want. But you could only make buttons or inputs or what ever on the last tab I think. You can't create stuff on for example the 2nd one.

I think mine

Func _Create_Tab($left, $top, $width, $height, $name, $style = "", $exstyle = "")
    GUICtrlCreateTab($left, $top, $width, $height, $style, $exstyle)
    GUICtrlCreateTabItem($name)
EndFunc

Is just more usefull.

Just my toughts...

AlmarM

I'm lost on how this is useful at all to be honest. I can't remember when I ever created just 1 tab item for a tab. You don't return the control id for the tab or the item to be interacted with later on. In it's current setup, it's a useless function.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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
Sign in to follow this  
Followers 0