native-windows-gui icon indicating copy to clipboard operation
native-windows-gui copied to clipboard

Default background colors are wrong

Open robeady opened this issue 4 years ago • 6 comments

In various places, this library uses code like the following to obtain the default background color:

https://github.com/gabdube/native-windows-gui/blob/19938bd7b1d0a52055e66bd0705967f905796a81/native-windows-gui/src/win32/window.rs#L430

This code is missing a + 1 when reinterpreting a color constant as an HBrush. This results in a default background colour of COLOR_MENU rather than COLOR_WINDOW. See https://devblogs.microsoft.com/oldnewthing/20140305-00/?p=1593 for more details.

robeady avatar Apr 11 '21 17:04 robeady

There are a few more incorrect HBRUSH casts for COLOR_WINDOW, and I also found this one for tab colors: https://github.com/gabdube/native-windows-gui/blob/057ed70cf85620bb44d816aef68f919eba4660fb/native-windows-gui/src/win32/tabs.rs#L23

Not sure if I missed some others

robeady avatar Apr 11 '21 18:04 robeady

Well... not sure if I want to change the default background now that it's been that way for 12 versions. Nice to know why we I need to add a +1 to the color value though.

gabdube avatar Apr 12 '21 18:04 gabdube

Well... not sure if I want to change the default background now that it's been that way for 12 versions. Nice to know why we I need to add a +1 to the color value though.

Hmm, ok. How about providing a convenient way for the user to correct it? At the moment I don't see a good way to customise anything about the window class without reimplementing a large chunk of window creation code.

Maybe I missed an easy way to change the window background though

robeady avatar Apr 13 '21 01:04 robeady

Ok that's a good idea. I will add a new builder field for the window background

gabdube avatar Apr 13 '21 01:04 gabdube

Uh, it's a little silly to not fix a blatant issue because people are using the version of the code that is wrong. This is why we have semantic versioning, to indicate breaking changes.

spikespaz avatar Dec 26 '21 01:12 spikespaz

Ok that's a good idea. I will add a new builder field for the window background

Is it added yet? I can't find it

lemon-sh avatar Jan 03 '23 21:01 lemon-sh