From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- dlls/windows.ui/Makefile.in | 2 +- dlls/windows.ui/uisettings.c | 45 ++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/dlls/windows.ui/Makefile.in b/dlls/windows.ui/Makefile.in index cb9b48a664b..592d023f353 100644 --- a/dlls/windows.ui/Makefile.in +++ b/dlls/windows.ui/Makefile.in @@ -1,5 +1,5 @@ MODULE = windows.ui.dll -IMPORTS = combase +IMPORTS = combase advapi32
C_SRCS = \ main.c \ diff --git a/dlls/windows.ui/uisettings.c b/dlls/windows.ui/uisettings.c index f2ae024de1b..7f120eafbdb 100644 --- a/dlls/windows.ui/uisettings.c +++ b/dlls/windows.ui/uisettings.c @@ -117,10 +117,51 @@ static const struct IActivationFactoryVtbl factory_vtbl =
DEFINE_IINSPECTABLE( statics3, IUISettings3, struct uisettings_statics, IActivationFactory_iface )
+static DWORD get_windows_color_mode(void) +{ + static const WCHAR *subkey = L"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"; + static const WCHAR *name = L"AppsUseLightTheme"; + static const HKEY root = HKEY_CURRENT_USER; + DWORD ret, len = sizeof(ret), type; + HKEY hkey; + + if (RegOpenKeyExW( root, subkey, 0, KEY_QUERY_VALUE, &hkey )) return 1; + if (RegQueryValueExW( hkey, name, NULL, &type, (BYTE *)&ret, &len ) || type != REG_DWORD) ret = 1; + RegCloseKey( hkey ); + return ret; +} + +static void set_color_value( BYTE a, BYTE r, BYTE g, BYTE b, Color *out ) +{ + out->A = a; + out->R = r; + out->G = g; + out->B = b; +} + static HRESULT WINAPI statics3_GetColorValue( IUISettings3 *iface, UIColorType type, Color *value ) { - FIXME( "iface %p, type %d, color %p stub!\n", iface, type, value ); - return E_NOTIMPL; + DWORD light_theme; + + TRACE( "iface %p, type %d, value %p.\n", iface, type, value ); + + switch (type) { + case UIColorType_Foreground: + case UIColorType_Background: + light_theme = get_windows_color_mode(); + break; + default: + FIXME( "type %d not implemented.\n", type ); + return E_NOTIMPL; + } + + if (type == UIColorType_Foreground) + set_color_value( 0, light_theme ? 0 : 255, light_theme ? 0 : 255, light_theme ? 0 : 255, value ); + else + set_color_value( 0, light_theme ? 255 : 0, light_theme ? 255 : 0, light_theme ? 255 : 0, value ); + + TRACE( "Returning value.A = %d, value.R = %d, value.G = %d, value.B = %d\n", value->A, value->R, value->G, value->B ); + return S_OK; }
static HRESULT WINAPI statics3_add_ColorValuesChanged( IUISettings3 *iface, ITypedEventHandler_UISettings_IInspectable *handler, EventRegistrationToken *cookie )