Jump to content
Sign in to follow this  
kaotkbliss

How to set a tab as active?

Recommended Posts

kaotkbliss

I'm trying to save the current active tab to an ini, then later when the gui is redrawn, set the active tab to what was saved in the ini but I can't seem to figure it out.

#include <GUIConstantsEx.au3>

Global $htab, $curtab

$1 = InputBox("Enter Tab 1 Name", "Enter a Name for Tab 1", "Tab1")
$2 = InputBox("Enter Tab 2 Name", "Enter a Name for Tab 2", "Tab2")
$3 = InputBox("Enter Tab 3 Name", "Enter a Name for Tab 3", "Tab3")
IniWrite(@WorkingDir & "\pldata.ini", "Tab", 1, $1)
IniWrite(@WorkingDir & "\pldata.ini", "Tab", 2, $2)
IniWrite(@WorkingDir & "\pldata.ini", "Tab", 3, $3)

$tab1 = IniRead(@WorkingDir & "\pldata.ini", "Tab", 1, "Tab1")
$tab2 = IniRead(@WorkingDir & "\pldata.ini", "Tab", 2, "Tab2")
$tab3 = IniRead(@WorkingDir & "\pldata.ini", "Tab", 3, "Tab3")

$curtab=IniRead(@WorkingDir & "\pldata.ini","curtab",1,$tab1)

$main = GUICreate("Program Launcher", 350, 446, -1, -1)
$htab=GUICtrlCreateTab(2, 2, 346, 426)
$win = GUICtrlCreateTabItem($tab1)
$win2 = GUICtrlCreateTabItem($tab2)
$win3 = GUICtrlCreateTabItem($tab3)
GUICtrlCreateTabItem("")
GUISwitch ($main, $curtab)
GUISetState(@SW_SHOW)

While 1
    $msg=GUIGetMsg()
    If $msg=$GUI_EVENT_CLOSE Then
        $curtab=GUICtrlRead($htab)
        IniWrite(@WorkingDir & "\pldata.ini","curtab",1,$curtab)
        GUIDelete()
        Exit (1)
    EndIf
WEnd

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites
AdmiralAlkex

1. Your current way doesn't even work in theory. GUISwitch() needs a control id, and you give it the index. You should have set the advanced parameter of GUICtrlRead(). See GUISwitch(), GUICtrlCreateTabItem() and GUICtrlRead() in the helpfile.

2. Read the page for GUICtrlCreateTabItem() in the helpfile again. Notice the second remark?

To select a specific tabitem to be shown when the dialog box open just issue a GUICtrlSetState(-1,$GUI_SHOW) see example.

So to fix you script, change to:

GUICtrlCreateTabItem("")
GUICtrlSetState($curtab, $GUI_SHOW)
GUISetState(@SW_SHOW)

And voila! :blink:

  • Like 1

Share this post


Link to post
Share on other sites
kaotkbliss

Thank you much!

I figured there was an easy way, I was so busy looking for a function, I missed the additional parameters.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.