Sign in to follow this  
Followers 0
SlowCoder74

Adding tabs to a tab control ... before the existing tabs

5 posts in this topic

#1 ·  Posted (edited)

I'm working on an application that starts with 2 tabs. Upon a user's login, it will present them with 2 more tabs. It's easy enough to add the new tabs. But I'd like the new tabs to appear to the left of the existing tabs. Is there any way to accomplish this in AutoIT? ... or maybe to hide the tabs until it's time to show them?

Edited by SlowCoder74

Share this post


Link to post
Share on other sites



SlowCoder74,

I think you will have to use the UDF functions for that:

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>

$hGUI = GUICreate("Test", 500, 500)

$hTab = _GUICtrlTab_Create($hGUI, 10, 10, 480, 300)

$hTab_0 = _GUICtrlTab_InsertItem($hTab, 0, "0")

$hTab_1 = _GUICtrlTab_InsertItem($hTab, 1, "1")

$cButton = GUICtrlCreateButton("Add", 10, 400, 80, 30)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton
            $hTab_2 = _GUICtrlTab_InsertItem($hTab, 0, "2")
            $hTab_3 = _GUICtrlTab_InsertItem($hTab, 1, "3")
    EndSwitch
WEnd

Or you could just delete and recreate the entire tab control if you want to use the native functions:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$cTab = GUICtrlCreateTab(10, 10, 480, 300)

$cTab_0 = GUICtrlCreateTabItem("0")
$cTab_1 = GUICtrlCreateTabItem("1")
GUICtrlCreateTabItem("")

$cButton = GUICtrlCreateButton("Add", 10, 400, 80, 30)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cButton
            GUICtrlDelete($cTab)
            $cTab = GUICtrlCreateTab(10, 10, 480, 300)
            $cTab_0 = GUICtrlCreateTabItem("-2")
            $cTab_1 = GUICtrlCreateTabItem("-1")
            $cTab_2 = GUICtrlCreateTabItem("0")
            $cTab_3 = GUICtrlCreateTabItem("1")
    EndSwitch
WEnd

Any use? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi, slowcoder74. You mention after the user logs in. Do all users have the same rights on login, or are you attempting to set up different rights for different users? Depending on how you're handling your security (A.D. integrated, etc.) there are a couple of ways you could do this.

Dang, too slow ;)

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

@Melba23, I was moving in the direction of destroying and recreating, but I'll check out that UDF you posted. Thanks!

@JLocal3o13, My application is designed to provide read-only information about the logged in Windows user and PC. Network admins can log into my app for more advanced management functions.

FYI: In another attempt, I created a tabbed control with an embedded group control. When I disabled or hid the group control using GUICtrlSetState($Group1, $GUI_DISABLE), it remained enabled. I guess group controls can't be disabled or hidden? Here's my test code.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 413, 305, 245, 167)
$Tab1 = GUICtrlCreateTab(48, 24, 281, 169)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
GUICtrlSetState(-1,$GUI_SHOW)
$Group1 = GUICtrlCreateGroup("Group1", 88, 64, 177, 97)
$Button1 = GUICtrlCreateButton("Button1", 112, 88, 97, 25)
$Input1 = GUICtrlCreateInput("Input1", 120, 112, 121, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetState(-1, $GUI_HIDE)
$Button2 = GUICtrlCreateButton("Enable", 128, 168, 73, 17)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  case $Button2
   GUICtrlSetState($Group1,$GUI_ENABLE)
   GUICtrlSetState($Group1,$GUI_SHOW)
EndSwitch
WEnd

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You could always go the A.D. Security Group route, do something like this at the beginning, and then present the GUI based on whether the user is or is not in the group.

Func _InGroup()

_AD_Open()

$sFQDN_User = _AD_SamAccountNameToFQDN()
$sFQDN_Group = "MyAppGroup"
$ingroup = _AD_IsMemberOf($sFQDN_Group, $sFQDN_User, False)
_AD_Close()

EndFunc
Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

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