Jump to content

Create GUI Controller on a previously created tab


Recommended Posts

Hello !

How do I create a GUI Controller on a previosuly used Tab.

I have created Tab 1, Tab 2 and Tab 3, then I wan't to create a controller on Tab 1, how do I change to set focus on Tab 1 to create the controller there.

/Sven

Link to comment
Share on other sites

  • Moderators

#include <GUIConstants.au3>

GUICreate("My GUI Tab"); will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab=GUICtrlCreateTab (10,10, 200,100)

$tab0=GUICtrlCreateTabitem ("tab0")
GUICtrlCreateLabel ("label0", 30,80,50,20)
$tab0OK=GUICtrlCreateButton ("OK0", 20,50,50,20)
$tab0input=GUICtrlCreateInput ("default", 80,50,70,20)

$tab1=GUICtrlCreateTabitem ( "tab----1")
GUICtrlCreateLabel ("label1", 30,80,50,20)
$tab1combo=GUICtrlCreateCombo ("", 20,50,60,40)
GUICtrlSetData(-1,"Trids|CyberSlug|Larry|Jon|Tylo", "Jon"); default Jon
$tab1OK=GUICtrlCreateButton ("OK1", 80,50,50,20)

$tab2=GUICtrlCreateTabitem ("tab2")
GUICtrlCreateLabel ("label2", 30,80,50,20)
$tab2OK=GUICtrlCreateButton ("OK2", 140,50,50)

GUICtrlCreateTabitem ("") ; end tabitem definition

GUICtrlCreateLabel ("label3", 20,130,50,20)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $tab0OK Then GUICtrlSetState($tab1, $GUI_SHOW)
Wend
Click the button, and it will focus now on tab 2 with GUICtrlSetState()

Edit:

P.S. - I got this Tab example from the help file... it actually has you question answered right in it... when you start the GUI in the GUICtrlCreateTab() section of the Help File, there it shows tab 3 first... it uses GUICtrlSetState(-1, $GUI_SHOW), I altered my example to show you how you could do it with a button.

Edited by SmOke_N

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.

Link to comment
Share on other sites

  • Moderators

You don't need a button to do it, I was merely showing you how it could be done... you could simply make it a conditional statement if you want too.

Edit:

This does not show the 'Same' Button, because we are using TabItem after Tab

#include <guiconstants.au3>
$TestGUI = GUICreate('Testing', 200, 100)
$TAB = GUICtrlCreateTab(0, 0, 200, 100)
$TABITEM1 = GUICtrlCreateTabItem('TAB 1')
$TABBUTTON1 = GUICtrlCreateButton('BUTTON FOR TAB 1', 10, 30, 120, 30)
$TABITEM2 = GUICtrlCreateTabItem('TAB 2')
$TABBUTTON2 = GUICtrlCreateButton('BUTTON FOR TAB 2', 75, 65, 120, 30); DIFFERENT POSITION SO YOU CAN SEE THE DIFFERENCE

GUISetState()

While 1
    $MSG = GUIGetMsg()
    If $MSG = - 3 Then Exit
    If $MSG = $TABBUTTON1 Then GUICtrlSetState($TABITEM2, $GUI_SHOW)
    If $MSG = $TABBUTTON2 Then GUICtrlSetState($TABITEM1, $GUI_SHOW)
WEnd
Edited by SmOke_N

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.

Link to comment
Share on other sites

I don't think you really understand the problem, If I have an event, that triggers on a button located on tab1, and that event creates a new GUICtrlCreatebutton that should be located on TAB1, it will show up on all TABs, not only the first.

/Sven

Link to comment
Share on other sites

  • Moderators

Well, I've seem to have done something you haven't.. supplied code... want to try and give that a shot... I'm pretty sure if you use the example I provided above, you'll see in fact that your response is not the case... unless you are recreating buttons etc...

Edit:

I think I jumped the gun a bit myself, after reading your post over and over a few times....

Edit2:

I tried all the functions in the help file... unless GaFrost/Cyber/Larry or any other Dev has an Idea, I'm clueless... The only thing I could do was destroy and recreate.... Sorry for mis-understanding your post.

Edited by SmOke_N

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.

Link to comment
Share on other sites

  • Moderators

Ok, I take back my last edit... "I thought I tried everything", is this what you are looking for?

#include <GUIConstants.au3>
Local $TABBUTTON[10]
$TestGUI = GUICreate('Testing', 200, 100)
$TAB = GUICtrlCreateTab(0, 0, 200, 100)
$TABITEM1 = GUICtrlCreateTabItem('TAB 1')
$TABBUTTON[1] = GUICtrlCreateButton('BUTTON FOR TAB 1', 10, 30, 120, 30)
$TABITEM2 = GUICtrlCreateTabItem('TAB 2')

GUISetState()

While 1
    $MSG = GUIGetMsg()
    If $MSG = - 3 Then Exit
    If $MSG = $TABBUTTON[1] Then
        GUISwitch($TestGUI, $TABITEM1)
        $TABBUTTON[2] = GUICtrlCreateButton('BUTTON2 FOR TAB1', 75, 65, 120, 30)
        GUICtrlSetState($TABBUTTON[2], $GUI_SHOW)
        GUICtrlCreateTabItem("")
    EndIf
WEnd

Edit: Needs Beta...

Edited by SmOke_N

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.

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...