Jump to content

How to allow tab order to step to images posing as buttons?


Mbee
 Share

Recommended Posts

I first want to thank all the many knowledgeable and generous posters here who have so graciously lent their time and efforts to helping me recently!  These inlude (but are not limited to!): @Melba23, @UEZ, @mikell, @AutoBert, @trancexx, @Chimp, and others. Thanks!!

Okay, now for a new issue: I have an older GUI app that used plain old non-colored buttons, which allowed the user to tab through the various controls in order. Recently, I updated it to simulate colored buttons (which are strictly verbotten) by first creating various jpegs which look like colored buttons, then using the marvellous BinaryToAu3Kompressor.exe to generate base64 data representing these jpegs, which are then loaded into memory instead of being loaded via file I/O.

But, of course and alas, the user can no longer tab through these simulated buttons as they could through real buttons.

So I found these new GUI thingies called tabs, and read the very helpful tutorial on them at: https://www.autoitscript.com/wiki/Tabs. Unfortunately, after much trial and eternal failure, I just can't get the simu-buttons to allow tabbing as usual. Not only that, but assuming I could figure out how to do that, how can I possibly insert them in the right order to match what would happen with real buttons (since there are still plenty of real buttons and text controls still left)?  Maybe I'm asking far too much for a non-AutoIt expert...

Anyway, well before I can worry about tab order, I still have to get the simu-buttons to be tabbable at all, and I'm lost.  Here are my code snipetts (by the way, I'm not at all sure which Styles and Extended Styles and the like to use).

Note that I'd prefer calling the _GUICtrlCreateTabItem() funcs with just a space (I realize I can't call them with a null string until the tab list is to be closed), but I added "btnx" here for clarity.  Also, _My_SetCtrlImage() sets the simu-button to the binary image passed it (and BTW the _My... stuff isn't ego, it's to help me recall which functions are coded by myself versus coded by others):

;
;
;   Set up to allow tabbing to image buttons as if they were real buttons...
;
Global $G_TabArea = GUICtrlCreatetab( 26,214,340,30, BitOr($TCS_FIXEDWIDTH, $TCS_BUTTONS, $GUI_ENABLE) ,$WS_EX_TRANSPARENT)
;~ ;
Global $G_RecTabCtrlID = GUICtrlCreateTabItem("btn1")
GUICtrlSetState( $G_RecTabCtrlID, $GUI_SHOW + $GUI_ENABLE )
_My_SetCtrlImage( $G_RecButtonCtl, $G_EnaRecBtnImage )
_GUICtrlTab_SetCurFocus( $G_TabArea, 0 )    ; Set tab focus on Record button
;
Global $G_StopTabCtrlID = GUICtrlCreateTabItem("btn2")
GUICtrlSetState( $G_StopTabCtrlID, $GUI_HIDE )
_My_SetCtrlImage( $G_StopButtonCtl, $G_DisStopBtnImage )
;
Global $G_ResetTabCtrlID = GUICtrlCreateTabItem("btn3")
GUICtrlSetState( $G_StopTabCtrlID, $GUI_HIDE )
_My_SetCtrlImage( $G_ResetButtonCtl, $G_DisResetBtnImage )
;
GUICtrlCreateTabItem("")                ; Close Tab Area
;
GUICtrlSetState( $G_RecButtonCtl, $GUI_ENABLE )
GUICtrlSetState( $G_StopButtonCtl, $GUI_DISABLE )
GUICtrlSetState ($G_ResetButtonCtl, $GUI_DISABLE )

When I run the app, there are at least two failures obvious: (1) The simu-buttons never get tabbed to (the keyboard tab button skips right past 'em, and (2): A totally unwanted thick dark line is drawn between the buttons on the GUI!

What am I doing wrong and deserve scolding as a noob for?

Thanks!

Edited by Mbee
typo
Link to comment
Share on other sites

  • Moderators

Mbee,

I am very unclear as to what you want to do here.

You can use the {TAB} key to move between controls in a specific order because there is a $WS_TABSTOP style which tells Windows to allow this to happen - I do not believe you can apply this style to tabs. But you could do something like this:

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <MsgBoxConstants.au3>

$hGUI = GUICreate("Test", 500, 500)

Global $G_TabArea = GUICtrlCreateTab(26, 214, 340, 30)
$G_RecTabCtrlID = GUICtrlCreateTabItem("btn1")
$G_StopTabCtrlID = GUICtrlCreateTabItem("btn2")
$G_ResetTabCtrlID = GUICtrlCreateTabItem("btn3")
GUICtrlCreateTabItem("")

$cTabDummy = GUICtrlCreateDummy()

GUISetState()

Global $aAccelKeys[1][2] = [["{TAB}", $cTabDummy]]
GUISetAccelerators($aAccelKeys)

Global $iTabIndex = 0

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cTabDummy
            $iTabIndex = Mod($iTabIndex + 1, 3)
            _GUICtrlTab_ClickTab($G_TabArea, $iTabIndex)
        Case $G_TabArea
            $iSelIndex = GUICtrlRead($G_TabArea) + 1
            MsgBox($MB_SYSTEMMODAL, "Selected", "Tab: " & $iSelIndex)
    EndSwitch
WEnd

Now the {TAB} key will move between the tabs and select them - but as you are not displaying anything on the different tabs not a lot happens.

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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