AHK/Windows Gui glitch or error in code?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ahk7
Posts: 574
Joined: 06 Nov 2013, 16:35

AHK/Windows Gui glitch or error in code?

Post by ahk7 » 10 May 2021, 13:16

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 377 times
Last edited by ahk7 on 11 May 2021, 12:35, edited 1 time in total.
gregster
Posts: 8916
Joined: 30 Sep 2013, 06:48

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

Post by gregster » 10 May 2021, 13:27

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...
User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

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

Post by mikeyww » 10 May 2021, 13:48

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
ahk7
Posts: 574
Joined: 06 Nov 2013, 16:35

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

Post by ahk7 » 11 May 2021, 12:36

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
lexikos
Posts: 9552
Joined: 30 Sep 2013, 04:07
Contact:

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

Post by lexikos » 12 May 2021, 03:47

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"");
ahk7
Posts: 574
Joined: 06 Nov 2013, 16:35

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

Post by ahk7 » 12 May 2021, 12:43

I see, thank you. Probably not wise to make it OS dependent don't strip the theme for say Windows 10.
lexikos
Posts: 9552
Joined: 30 Sep 2013, 04:07
Contact:

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

Post by lexikos » 13 May 2021, 23:18

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

Return to “Ask for Help (v1)”