JimEarlT

Trying to set text color on a radio button control

3 posts in this topic

Hi oh wise ones,

     I must be missing something really basic here.  I am trying to change the text color of the label of a radio button.  I can change the background color of the radio button without any problems but seem to be unable to change the text color.  Attached is a simple test script that shows the problem.  System is Autoit3 running on a Windows 10 x64 system. I am running the script as a 32bit script though.  I have very little hair left to pull out so any help is deeply appreciated.

 

TestScript.au3

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Read in Helpfile the Remarks to GuiSetColor,

Using:

DllCall('uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 0) ; Classic-Style

switching to Classic Style before creating the radio  and your script does what you excpect.

Edited by AutoBert

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Another old example which I found on my disk:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("Form1", 324, 222, 192, 124)
$Radio1 = GUICtrlCreateRadio("", 104, 72, 14, 17)
;~ DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Radio1), "wstr", 0, "wstr", 0)
$Label = GUICtrlCreateLabel("Radio One", 121, 70, 100, 17)
$hLabel = GUICtrlGetHandle($Label)
GUICtrlSetFont(-1, 12, 400, 0, "Palatino Linotype")
GUICtrlSetColor(-1, 0xFF0000)

$Radio2 = GUICtrlCreateRadio("Radio Two", 104, 110, 113, 17)
GUICtrlSetFont(-1, 12, 400, 0, "Palatino Linotype")
GUICtrlSetColor(-1, 0xFF0000)

GUISetState(@SW_SHOW)

Global $hLabelWndProc = DllCallbackRegister("LabelWndProc", "long", "hwnd;uint;wparam;lparam")
Global $hOldLabelProc = _WinAPI_SetWindowLong($hLabel, $GWL_WNDPROC, DllCallbackGetPtr($hLabelWndProc))

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _WinAPI_SetWindowLong($hLabel, $GWL_WNDPROC, $hOldLabelProc)
            DllCallbackFree($hLabelWndProc)
            GUIDelete()
            Exit

    EndSwitch
WEnd

Func LabelWndProc($hWnd, $iMsg, $wParam, $lParam)
    Switch $iMsg
        Case $WM_LBUTTONDOWN
            GUICtrlSetState($Radio1, $GUI_CHECKED)
            GUICtrlSetState($Radio2, $GUI_UNCHECKED)
            ControlFocus($Form1, "", $Label)
    EndSwitch
    Return _WinAPI_CallWindowProc($hOldLabelProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>EditWndProc

 

Edited by UEZ
1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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