Getting system UI colours

  1. 2 weeks ago

    Garry P

    Sep 8 Pre-Release Testers, Xojo Pro Europe (Torquay, UK)
    Edited 2 weeks ago

    I’m using the MonkeyBread NSColorMBS class to get various (dark/light mode aware) system UI colours on macOS. For example, I can get the standard window background colour with NSColorMBS.windowBackgroundColor.

    Is there anyway (declares or plugins are fine) to get the standard Windows UI colours? I don’t know if Microsoft even have the concept of semantic colour naming. The alternative is using a colour picker and hard coding the values but I’d rather use an OS API if possible in case they change.

    Also, I know that the Xojo Application.AppearanceChanged event only works on macOS but I’ve noticed that Windows 10 now has a dark theme/mode too. Does anyone have a declare or other mechanism to know when this changes?

    @ChristianSchmitz ?

  2. Ivan T

    Sep 8 Pre-Release Testers
    Edited 2 weeks ago

    @Garry P I don’t know if Microsoft even have the concept of semantic colour naming.

    Microsoft had that since windows 95. Even in Visual Basic you can choose for a fixed color or a system color, being the controsl default to the system color. also a feature more than 2 decades old. Too bad Xojo lacks this very basic function, the controls have fixed colors, so, no native support for themes, or accesibility on high contrast configurations.

    I made Feedback Case #56952 asking to add 4 basic and missing colors from xojo.

    Windows had the capacity of a global dark theme since windows 95, Windows 10 dark theme is diferent and intended for Universal apps only.

    The declare for getting the system colors is the GetSysColor function

    For the lack of the AppearanceChanged, there is another Feedback Case #56451

    A workaround is to implement a WndProc to intercept the messages and listen for:

    • WM_SYSCOLORCHANGE 0x0015
    • WM_THEMECHANGED 0x031A
    • WM_DWMCOLORIZATIONCOLORCHANGED 0x0320
  3. Jean-Yves P

    Sep 8 Pre-Release Testers, Xojo Pro Europe (France, Besançon)
    Edited 2 weeks ago

    it seems implemented in the SystemColorWFS module of the Windows Functionnality Suite

    https://github.com/arbp/WFS
    https://github.com/arbp/WFS/blob/master/Windows%20Functionality%20Suite/System%20Information/Modules/SystemColorsWFS.rbbas

  4. Robin L

    Sep 8 Xojo Inc Europe (Germany, Rehlingen)

    Also https://forum.xojo.com/39009-windows-10-colorsettings/0

  5. last week

    Garry P

    Sep 9 Pre-Release Testers, Xojo Pro Europe (Torquay, UK)

    Thanks Ivan for the comprehensive reply. I have looked at your feedback issue and raised another (Feedback Case #57361).

    Do you have any code you can share about implementing a WndProc? I have experience with declares on macOS but none on Windows.

    Thank you for the link to the GetSysColor function. It's really hard to find stuff in the MS API docs!

    @Jean-YvesPochez I'll take a look at WFS. Thanks

  6. Norman P

    Sep 9 Pre-Release Testers, Xojo Pro great-white-software.com/blog

    WFS has an example WndProc in it
    Not sure its well explained though

  7. Ivan T

    Sep 9 Pre-Release Testers
    Edited last week

    @Garry P Thanks Ivan for the comprehensive reply. I have looked at your feedback issue and raised another (Feedback Case #57361).

    Do you have any code you can share about implementing a WndProc? I have experience with declares on macOS but none on Windows.

    Thank you for the link to the GetSysColor function. It's really hard to find stuff in the MS API docs!

    @Jean-YvesPochez I'll take a look at WFS. Thanks

    Hi

    For the WndProcm there is a good answer in the other thread.

    As for the dark mode, I think I ddidnt explain myself, Windows 10 is now divided between the clasic apps (the ones created with xojo) and the new UWP apps.

    GetSysColor and the theme messages; WM_SYSCOLORCHANGE, WM_THEMECHANGED, WM_DWMCOLORIZATIONCOLORCHANGED. work with win32 apps.

    If you change the UWP dark the setting, it does not send those messages and the GetSysColor will return the exact same colors either in dark or light theme. The win32 color themes is now more used as a high contrast setting.

    In the other hand, if you want to make a manual dark theme support, you can use GetSysColor in the light theme and custom colors for the dark theme.

    As for your FC, xojo can refuse because dark mode is not intended for Win32 apps like those created by xojo. as a workaround, once you implement the WndProc, you just have to also listen for the WM_WININICHANGE message in windows 10 and then read the Registry key :

    Current user\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize\AppsUseLightTheme

  8. Anthony C

    Sep 9 Pre-Release Testers, Xojo Pro, Third Party Store GraffitiSuite Developer
    Edited last week

    To get the colors needed in Windows you actually have to declare in to an undocumented function.

    I don't normally do this, but I'll be releasing GraffitiColors soon, which will include Windows Dark Mode support and all 1200+ system color definitions, in addition to the macOS colors and a number of other schemes/palettes.

    https://twitter.com/graffitisuite/status/1171085385461579776

  9. Garry P

    Sep 9 Pre-Release Testers, Xojo Pro Europe (Torquay, UK)

    I've summarised what I was looking for in this thread . Thanks everybody for chipping in. Lots of useful information.

  10. Anthony C

    Sep 9 Pre-Release Testers, Xojo Pro, Third Party Store GraffitiSuite Developer

    Yeah, in GraffitiColors, I've built a window subclass that handles all of this with Delegates.

or Sign Up to reply!