Jump to content

Make an action when click on a Tab item


Recommended Posts

Well, I want to change my GUI title when clicking on a tab item. I've tried something like this:

$tab1 = GUICtrlCreateTabItem("Tab1")
While 1
     $msg = GuiGetMsg()
          Case $msg = $tab1
                WinSetTitle("Old Title","","New Title")

It didn't work, in fact it didn't work with any action (like MsgBox). How can I make this happen?

Link to comment
Share on other sites

  • Developers

GUIGetMsg returns the handle of the GUICtrlCreateTab() not GUICtrlCreateTabitem.

So you need to check for that and then retrieve the selected tab by doing a GUICtrlRead()..

Heres an example:

#include <GUIConstants.au3>
Opt("WinTitleMatchMode", 1)
GUICreate("My GUI Tab"); will create a dialog box that when displayed is centered

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")
GUICtrlSetState(-1,$GUI_SHOW); will be display first
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 < 1 then ContinueLoop
    if $msg = $tab then
        if GUICtrlread ($tab) = 0 then WinSetTitle("My GUI Tab","","My GUI Tab0")
        if GUICtrlread ($tab) = 1 then WinSetTitle("My GUI Tab","","My GUI Tab1")
        if GUICtrlread ($tab) = 2 then WinSetTitle("My GUI Tab","","My GUI Tab2")
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
Live for the present,
Dream of the future,
Learn from the past.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...