Jump to content

Recommended Posts

Posted (edited)

Is there a way to disable the TabStop for the Radio button on this script?

With the "_Winapi....." line it is working but only partially. If I click on one of the radio button, the tabstop start to work again.

I cannot use Hotkeyset because I will run multiple instance of the script.

Thanks!

Alain

#include <Constants.au3>

#include <WinAPI.au3>

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

$Form1 = GUICreate("Test", 288, 284,-1,-1)

$Input1 = GUICtrlCreateInput("", 12, 8, 57, 21)

_WinAPI_SetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE), BitNOT($WS_TABSTOP)))

$radio1 = GUICtrlCreateRadio("Radio1", 150, 8, 55, 21)

GUICtrlSetState($radio1, $GUI_CHECKED)

_WinAPI_SetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE), BitNOT($WS_TABSTOP)))

$radio2 = GUICtrlCreateRadio("Radio2", 210, 8, 55, 21)

_WinAPI_SetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle(-1), $GWL_STYLE), BitNOT($WS_TABSTOP)))

GUISetState(@SW_SHOW)

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

EndSwitch

WEnd

test.au3

Edited by AlainB
Posted

Just bumping up my post.

The "winAPI...." lines in the script are lines that I took from another thread and they are working fine for inputs. They are not working well for Radio button.

Would there be another way to do what I want to do?

Many thanks!

Alain

  • Moderators
Posted (edited)

AlainB,

Interesting behaviour! :graduated:

It seems it is actually Windows doing it each time the Radio control is actioned via the BM_SETCHECK message:

"BM_SETCHECK - Sets the check state for all styles of radio buttons and check boxes. If the wParam parameter is greater than zero for radio buttons, the button is given the WS_TABSTOP style."

It seems the only solution is to reclear the TABSTOP style each time a Radio is actioned:

#include <Constants.au3>
#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
 
$Form1 = GUICreate("Test", 288, 284, -1, -1)
 
$Input1 = GUICtrlCreateInput("", 12, 8, 57, 21)
_No_TABSTOP($Input1)
$radio1 = GUICtrlCreateRadio("Radio1", 150, 8, 55, 21)
GUICtrlSetState($radio1, $GUI_CHECKED)
_No_TABSTOP($radio1)
$radio2 = GUICtrlCreateRadio("Radio2", 210, 8, 55, 21)
_No_TABSTOP($radio2)
GUISetState(@SW_SHOW)
 
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $radio1, $radio2
            _No_TABSTOP($nMsg)
    EndSwitch
WEnd
 
Func _No_TABSTOP($iCID)
 
    _WinAPI_SetWindowLong(GUICtrlGetHandle($iCID), $GWL_STYLE, BitAND(_WinAPI_GetWindowLong(GUICtrlGetHandle($iCID), $GWL_STYLE), BitNOT($WS_TABSTOP)))
 
EndFunc

Or you are into subclassing the Radio controls to change the WndProc - that I will leave to someone else! :)

M23

Edit: A bit more reading and I can see this behaviour is actually logical. Normally you have only the one Radio checked at any one time and that is the one to which you would want Windows to move the focus when you press the TAB key. So when setting a Radio to checked Windows will automatically reset the TABSTOP property for that control. At least you only need to clear the property for the checked control (as shown in the code above) and not all of them every time. ;)

Edited by Melba23

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

 

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