diff --git a/.editorconfig b/.editorconfig index eb127e6..95cc410 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,7 +6,8 @@ charset = "utf-8" end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true -indent_style = tab +indent_style = space +indent_size = 4 [*.md] indent_style = space diff --git a/ChewingTextService/ChewingTextService.cpp b/ChewingTextService/ChewingTextService.cpp index 0093c31..e002bf2 100644 --- a/ChewingTextService/ChewingTextService.cpp +++ b/ChewingTextService/ChewingTextService.cpp @@ -940,23 +940,26 @@ void TextService::hideMessage() { } bool TextService::isLightTheme() { - DWORD value = 0; - DWORD len = sizeof(value); - LSTATUS st = RegGetValueW( - HKEY_CURRENT_USER, - L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", - L"AppsUseLightTheme", - RRF_RT_REG_DWORD, - nullptr, - &value, - &len - ); - if (st != ERROR_SUCCESS) { - // assume light theme - return true; - } + DWORD value = 1; + DWORD dataSize = sizeof(value); + + LSTATUS result = RegGetValueW( + HKEY_CURRENT_USER, + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", + L"AppsUseLightTheme", + RRF_RT_DWORD, + nullptr, + &value, + &dataSize + ); + + if (result != ERROR_SUCCESS) { + OutputDebugStringW(L"Determine isLightTheme failed, fallback to light theme"); + return true; + } + // 0 = dark theme, 1 = light theme - return value > 0; + return value > 0; } void TextService::updateLangButtons() {