Jump to content

Tab focus


notta
 Share

Recommended Posts

It seems I can't set the focus on a tab with _GUICtrlTab_SetCurSel when using the label trick to set the background color of a tab.

I have inputs on a certain tab that I want a user to be able to go back and enter data into. It selects the tab, but I cannot see any of the controls unless I manually click another tab and then go back again. Here is an example:

#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiTab.au3>

Opt('MustDeclareVars', 1)

$Debug_TAB = False; Check ClassName being passed to functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
    Local $hTab
    Local $label
    Local $input1
    
; Create GUI
    GUICreate("Tab Control Set Current Selected", 400, 300)
    $hTab = GUICtrlCreateTab(2, 2, 396, 296)
    $label = GUICtrlCreateLabel("",8,25,1000,260)
    GUICtrlSetBkColor($label,0x34334)
    GUICtrlSetState($label,$GUI_DISABLE)
    
; Add tabs
    GUICtrlCreateTabItem("Tab 1")
    GUICtrlCreateTabItem("")
    GUICtrlCreateTabItem("Tab 2")
    GUICtrlCreateTabItem("")
    GUICtrlCreateTabItem("Tab 3")
    $input1 = GUICtrlCreateInput("",20,40,50,50)
    GUICtrlCreateTabItem("")
    GUISetState()
    
; Get/Set current selection
    _GUICtrlTab_SetCurSel($hTab, 1)
    MsgBox(4160, "Information", "Current Selection: " & _GUICtrlTab_GetCurSel($hTab))
    _GUICtrlTab_SetCurSel($hTab, 2)
    MsgBox(4160, "Information", "Current Selection: " & _GUICtrlTab_GetCurSel($hTab))

; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc  ;==>_Main

Any idea how I can set focus? I really don't want to use Send commands. Thanks.

Link to comment
Share on other sites

It seems I can't set the focus on a tab with _GUICtrlTab_SetCurSel when using the label trick to set the background color of a tab.

I have inputs on a certain tab that I want a user to be able to go back and enter data into. It selects the tab, but I cannot see any of the controls unless I manually click another tab and then go back again. Here is an example:

Any idea how I can set focus? I really don't want to use Send commands. Thanks.

Change your _GUICtrlTab_SetCurSel($hTab, {tab#}) to _GUICtrlTab_SetCurFocus($hTab, {tab#}).
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...