Sign in to follow this  
Followers 0
ranhalt

Read current active tab

2 posts in this topic

I've got a GUI with several tabs, obviously only one can be active at a time. I want to read which one is active. I will be taking action based on that, so an easy example would be just a unique msgbox. To whoever helps with this, I will eat a plate of fresh homemade cookies in your honor.

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiTab.au3>
#include <GuiScrollBars.au3>

$menu1 = GuiCreate("gui",400,500,-1,-1) ; GUI menu

;~ Menus
$filemenu = GUICtrlCreateMenu("&File") ; File menu
$fileitem = GUICtrlCreateMenuItem("&Exit", $filemenu) ; Exit menu

;~ The tab environment
$tab = GUICtrlCreateTab(0, 0, 403, 430,0x0002) ; Create tab

;~ Begin Tab 1
$tab1 = GUICtrlCreateTabItem("tab1") 

;~ Buttons
$button13=GuiCtrlCreateButton("Print",0,430,100,50) ; Print
$button14=GuiCtrlCreateButton("Print Screen",100,430,100,50)
$button15=GuiCtrlCreateButton("Run All",200,430,100,50) ; Run All scripts
$button16=GuiCtrlCreateButton("Exit",300,430,100,50) ; Exit

;~ End of Tab 1
;~ Begin Tab 2

$tab2 = GUICtrlCreateTabItem("tab2")
$button2x13=GuiCtrlCreateButton("Print",0,430,100,50) ; Print
$button2x14=GuiCtrlCreateButton("Print Screen",100,430,100,50)
$button2x15=GuiCtrlCreateButton("Run All",200,430,100,50) ; Run All scripts
$button2x16=GuiCtrlCreateButton("Exit",300,430,100,50) ; Exit

;~ End of Tab 2
;~ Begin Tab 3

$tab3 = GUICtrlCreateTabItem("tab3")
$button3x13=GuiCtrlCreateButton("Print",0,430,100,50) ; Print
$button3x14=GuiCtrlCreateButton("Print Screen",100,430,100,50)
$button3x15=GuiCtrlCreateButton("Run All",200,430,100,50) ; Run All scripts
$button3x16=GuiCtrlCreateButton("Exit",300,430,100,50) ; Exit

;~ End of Tab 3
;~ Begin Tab 4

$tab4 = GUICtrlCreateTabItem("tab4")
$button4x13=GuiCtrlCreateButton("Print",0,430,100,50) ; Print
$button4x14=GuiCtrlCreateButton("Print Screen",100,430,100,50)
$button4x15=GuiCtrlCreateButton("Run All",200,430,100,50) ; Run All scripts
$button4x16=GuiCtrlCreateButton("Exit",300,430,100,50) ; Exit

;~ End of Tab 4
;~ Begin Tab 5

$tab5 = GUICtrlCreateTabItem("tab5")
$button5x13=GuiCtrlCreateButton("Print",0,430,100,50) ; Print
$button5x14=GuiCtrlCreateButton("Print Screen",100,430,100,50)
$button5x15=GuiCtrlCreateButton("Run All",200,430,100,50) ; Run All scripts
$button5x16=GuiCtrlCreateButton("Exit",300,430,100,50) ; Exit

;~ End of Tab 5

GuiSetState()
While 1
$msg=GuiGetMsg() ; $msg = GUI input
;~ If $msg = GUI buttonX then goto function buttonX
If $msg=-3 Then Exit
; Tab 1 buttons

If $msg=$button13 Then button13()
If $msg=$button14 Then button14()
If $msg=$button15 Then button15()
If $msg=$button16 Then button16()

; Tab 2 buttons
If $msg=$button2x13 Then button13()
If $msg=$button2x14 Then button14()
If $msg=$button2x15 Then button15()
If $msg=$button2x16 Then button16()

; Tab 3 buttons
If $msg=$button3x13 Then button13()
If $msg=$button3x14 Then button14()
If $msg=$button3x15 Then button15()
If $msg=$button3x16 Then button16()

; Tab 4 buttons
If $msg=$button4x13 Then button13()
If $msg=$button4x14 Then button14()
If $msg=$button4x15 Then button15()
If $msg=$button4x16 Then button16()

; Tab 5 buttons
If $msg=$button5x13 Then button13()
If $msg=$button5x14 Then button14()
If $msg=$button5x15 Then button15()
If $msg=$button5x16 Then button16()
Wend

Func button13() ; Print Results - INCOMPLETE
EndFunc

Func button14() ; Print Screen - DONE
EndFunc

Func button15() ; Run All - INCOMPLETE
EndFunc

Func button16() ; Exit button - DONE
    Exit
EndFunc

Share this post


Link to post
Share on other sites



I think you want somethink like this?

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiTab.au3>
#include <GuiScrollBars.au3>

$menu1 = GuiCreate("gui",400,500,-1,-1) ; GUI menu

;~ Menus
$filemenu = GUICtrlCreateMenu("&File") ; File menu
$fileitem = GUICtrlCreateMenuItem("&Exit", $filemenu) ; Exit menu

;~ The tab environment
$tab = GUICtrlCreateTab(0, 0, 403, 430,0x0002) ; Create tab

;~ Begin Tab 1
$tab1 = GUICtrlCreateTabItem("tab1")

;~ Buttons
$button13=GuiCtrlCreateButton("Print",0,430,100,50) ; Print
$button14=GuiCtrlCreateButton("Print Screen",100,430,100,50)
$button15=GuiCtrlCreateButton("Run All",200,430,100,50) ; Run All scripts
$button16=GuiCtrlCreateButton("Exit",300,430,100,50) ; Exit

;~ End of Tab 1
;~ Begin Tab 2

$tab2 = GUICtrlCreateTabItem("tab2")
$button2x13=GuiCtrlCreateButton("Print",0,430,100,50) ; Print
$button2x14=GuiCtrlCreateButton("Print Screen",100,430,100,50)
$button2x15=GuiCtrlCreateButton("Run All",200,430,100,50) ; Run All scripts
$button2x16=GuiCtrlCreateButton("Exit",300,430,100,50) ; Exit

;~ End of Tab 2
;~ Begin Tab 3

$tab3 = GUICtrlCreateTabItem("tab3")
$button3x13=GuiCtrlCreateButton("Print",0,430,100,50) ; Print
$button3x14=GuiCtrlCreateButton("Print Screen",100,430,100,50)
$button3x15=GuiCtrlCreateButton("Run All",200,430,100,50) ; Run All scripts
$button3x16=GuiCtrlCreateButton("Exit",300,430,100,50) ; Exit

;~ End of Tab 3
;~ Begin Tab 4

$tab4 = GUICtrlCreateTabItem("tab4")
$button4x13=GuiCtrlCreateButton("Print",0,430,100,50) ; Print
$button4x14=GuiCtrlCreateButton("Print Screen",100,430,100,50)
$button4x15=GuiCtrlCreateButton("Run All",200,430,100,50) ; Run All scripts
$button4x16=GuiCtrlCreateButton("Exit",300,430,100,50) ; Exit

;~ End of Tab 4
;~ Begin Tab 5

$tab5 = GUICtrlCreateTabItem("tab5")
$button5x13=GuiCtrlCreateButton("Print",0,430,100,50) ; Print
$button5x14=GuiCtrlCreateButton("Print Screen",100,430,100,50)
$button5x15=GuiCtrlCreateButton("Run All",200,430,100,50) ; Run All scripts
$button5x16=GuiCtrlCreateButton("Exit",300,430,100,50) ; Exit

;~ End of Tab 5

GuiSetState()
While 1
$msg=GuiGetMsg() ; $msg = GUI input
Switch $msg
    Case $GUI_EVENT_CLOSE
            Exit
;~ If $msg = GUI buttonX then goto function buttonX

; Tab 1 buttons
    Case $tab
        Switch GUICtrlRead($tab)
    Case 0
        MsgBox(64,"TABITEM1","TABITEM1")
    Case 1
        MsgBox(64,"Tabitem2","Tabitem2")
    Case 2
        MsgBox(64,"Tbaitem 3","TABITEM3")
    Case 3
        MsgBox(64,"Tabitem 4","Tabitem 4")
    Case 4
        MsgBox(64,"Tabitem 5","Tabitem 5")
        ;
        EndSwitch
If $msg=$button13 Then button13()
If $msg=$button14 Then button14()
If $msg=$button15 Then button15()
If $msg=$button16 Then button16()

; Tab 2 buttons
If $msg=$button2x13 Then button13()
If $msg=$button2x14 Then button14()
If $msg=$button2x15 Then button15()
If $msg=$button2x16 Then button16()

; Tab 3 buttons
If $msg=$button3x13 Then button13()
If $msg=$button3x14 Then button14()
If $msg=$button3x15 Then button15()
If $msg=$button3x16 Then button16()

; Tab 4 buttons
If $msg=$button4x13 Then button13()
If $msg=$button4x14 Then button14()
If $msg=$button4x15 Then button15()
If $msg=$button4x16 Then button16()

; Tab 5 buttons
If $msg=$button5x13 Then button13()
If $msg=$button5x14 Then button14()
If $msg=$button5x15 Then button15()
If $msg=$button5x16 Then button16()
EndSwitch
Wend

Func button13() ; Print Results - INCOMPLETE
EndFunc

Func button14() ; Print Screen - DONE
EndFunc

Func button15() ; Run All - INCOMPLETE
EndFunc

Func button16() ; Exit button - DONE
    Exit
EndFunc

[size="5"] [/size]

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