Page 1 of 1

AHK/Windows Gui glitch or error in code?

Posted: 10 May 2021, 13:16
by ahk7
Windows 10, 64bit, AHK v1.1.33.09, dpi settings 150%
After I set the text color and set it back to black (which is default) the checkbox is no longer "flat" but has the "old skool" 3d look and is also a lot smaller - so is this my fault by not setting font and other style elements or a glitch in AutoHotkey or Windows? Test1, test2, and test3 have the same text size, but as you can see from the screenshot - the checkbox of Test3 is different, setting fontsize to 10 keeps it the same (test4)

Code: Select all

#NoEnv
#SingleInstance, force

Gui, Add, Checkbox,Checked1, TEST1 ; font 9 default I think
Gui, font, cGreen
Gui, Add, text,            , TEST2 ; font 9
Gui, font, cBlack                
Gui, Add, Checkbox,Checked1, TEST3 ; font 9 but checkbox is smaller??
Gui, font, s10 cBlack                
Gui, Add, Checkbox,Checked1, TEST4 ; font 10 but checkbox is still smaller/different style?

Gui, Show, center w270, test1234
Return

GuiClose:
ExitApp
test1234.png
test1234.png (4.9 KiB) Viewed 405 times

Re: AHK/Windows Gui glitch or error in code?

Posted: 10 May 2021, 13:27
by gregster
Huh, not sure why this happens, but it seems you can reset the style by using:

Code: Select all

Gui, font
Not that this helps much, if you want to use different colors in the same GUI...

Re: AHK/Windows Gui glitch or error in code?

Posted: 10 May 2021, 13:48
by mikeyww
Strange, but the following is a workaround.

Code: Select all

Gui, Font, s10 cBlack
Gui, Add, Checkbox, Checked1, TEST1
Gui, Font, cGreen
Gui, Add, Text,             , TEST2
Gui, Font, cBlack
Gui, Add, Checkbox, Checked1, TEST3
Gui, Add, Checkbox, Checked1, TEST4
Gui, Show, Center w270, Test

Re: AHK/Windows Gui glitch or error in code?

Posted: 11 May 2021, 12:36
by ahk7
Indeed that fixes it, it effects checkboxes and radio buttons (they also get the 3D treatment) - I do wonder it it is an AutoHotkey bug

@lexikos

Re: AHK/Windows Gui glitch or error in code?

Posted: 12 May 2021, 03:47
by lexikos
No, it is by design.

Code: Select all

	// Strip theme from the control if called for:
	// It is stripped for radios, checkboxes, and groupboxes if they have a custom text color.
	// Otherwise the transparency and/or custom text color will not be obeyed on XP, at least when
	// a non-Classic theme is active.  For GroupBoxes, when a theme is active, it will obey 
	// custom background color but not a custom text color.  The same is true for radios and checkboxes.
	if (do_strip_theme || (control.union_color != CLR_DEFAULT && (control.type == GUI_CONTROL_CHECKBOX
		|| control.type == GUI_CONTROL_RADIO || control.type == GUI_CONTROL_GROUPBOX)) // GroupBox needs it too.
		|| (control.type == GUI_CONTROL_GROUPBOX && (control.attrib & GUI_CONTROL_ATTRIB_BACKGROUND_TRANS))   ) // Tested and found to be necessary.)
		MySetWindowTheme(control.hwnd, L"", L"");

Re: AHK/Windows Gui glitch or error in code?

Posted: 12 May 2021, 12:43
by ahk7
I see, thank you. Probably not wise to make it OS dependent don't strip the theme for say Windows 10.

Re: AHK/Windows Gui glitch or error in code?

Posted: 13 May 2021, 23:18
by lexikos
I see no reason to consider doing that. I assume the "visual style" would still override the text colour. The behavior is not limited to XP; the comment is just that old.