Sign in to follow this  
Followers 0
Marklar

Setting default button per tab

4 posts in this topic

I have three tabs each with a search button and field. I would like the user to be able to type in the query then press enter to automatically execute the search.

I tired putting this code after each search button in each tab

GUICtrlSetState(-1,$GUI_DEFBUTTON)

It only works on the button in the last tab because that code really sets it to be the default button of the whole window and not just the single tab.

How can i get around that?

Thanks

Share this post


Link to post
Share on other sites



I have three tabs each with a search button and field. I would like the user to be able to type in the query then press enter to automatically execute the search.

I tired putting this code after each search button in each tab

GUICtrlSetState(-1,$GUI_DEFBUTTON)

It only works on the button in the last tab because that code really sets it to be the default button of the whole window and not just the single tab.

How can i get around that?

Thanks

Have you tried using the ID no. of the button instead of -1

Regards

Gerry

Share this post


Link to post
Share on other sites

Here's one way, there's probably other ways.

#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")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
$tab2OK = GUICtrlCreateButton("OK2", 140, 50, 50)
GUICtrlSetState($tab2OK, $GUI_DEFBUTTON)

GUICtrlCreateTabItem("") ; end tabitem definition

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

GUISetState()
$tb = 2
; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $tab0OK
            MsgBox(0, "test", "$tab0OK")
        Case $msg = $tab1OK
            MsgBox(0, "test", "$tab1OK")
        Case $msg = $tab2OK
            MsgBox(0, "test", "$tab2OK")
        Case Else
            If $tb <> GUICtrlRead($tab) Then
                $tb = GUICtrlRead($tab)
                Select
                    Case $tb = 0
                        GUICtrlSetState($tab0OK, $GUI_DEFBUTTON)
                    Case $tb = 1
                        GUICtrlSetState($tab1OK, $GUI_DEFBUTTON)
                    Case $tb = 2
                        GUICtrlSetState($tab2OK, $GUI_DEFBUTTON)
                EndSelect
            EndIf
    EndSelect
WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Worked perfect thank you very much

Edited by Marklar

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