Skip to content

Commit

Permalink
support different light/dark tray icons
Browse files Browse the repository at this point in the history
  • Loading branch information
dinhngtu committed May 30, 2021
1 parent efffd69 commit 68f94e9
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 12 deletions.
31 changes: 25 additions & 6 deletions VietTypeATL/LanguageBarHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,21 @@ static HRESULT OnMenuSelectAll(_In_ UINT id, _In_ EngineController* controller)
return S_OK;
}

static DWORD GetSystemLightTheme() {
CRegKey key;
DWORD light = 0;
LSTATUS err = key.Open(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", KEY_QUERY_VALUE);
if (err == ERROR_SUCCESS) {
err = key.QueryDWORDValue(L"SystemUsesLightTheme", light);
if (err != ERROR_SUCCESS) {
light = 0;
}
} else {
light = 0;
}
return light;
}

////////////////////////////////////////////////////////////////////////////////
// RefreshableButton
////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -261,12 +276,14 @@ HRESULT IndicatorButton::GetIcon(__RPC__deref_out_opt HICON* hicon) {
DBG_DPRINT(L"%s", L"cannot obtain instance");
return E_FAIL;
}

DWORD light = GetSystemLightTheme();
if (_controller->GetBlocked() == EngineController::BlockedKind::Blocked) {
*hicon = static_cast<HICON>(LoadImage(Globals::DllInstance, MAKEINTRESOURCE(IDI_ICONX), IMAGE_ICON, 16, 16, 0));
*hicon = static_cast<HICON>(LoadImage(Globals::DllInstance, MAKEINTRESOURCE(light ? IDI_ICONXL : IDI_ICONXD), IMAGE_ICON, 16, 16, 0));
} else if (_controller->IsEnabled()) {
*hicon = static_cast<HICON>(LoadImage(Globals::DllInstance, MAKEINTRESOURCE(IDI_ICONV), IMAGE_ICON, 16, 16, 0));
*hicon = static_cast<HICON>(LoadImage(Globals::DllInstance, MAKEINTRESOURCE(light ? IDI_ICONVL : IDI_ICONVD), IMAGE_ICON, 16, 16, 0));
} else {
*hicon = static_cast<HICON>(LoadImage(Globals::DllInstance, MAKEINTRESOURCE(IDI_ICONE), IMAGE_ICON, 16, 16, 0));
*hicon = static_cast<HICON>(LoadImage(Globals::DllInstance, MAKEINTRESOURCE(light ? IDI_ICONEL : IDI_ICONED), IMAGE_ICON, 16, 16, 0));
}
return *hicon ? S_OK : E_FAIL;
}
Expand Down Expand Up @@ -322,12 +339,14 @@ HRESULT LangBarButton::GetIcon(__RPC__deref_out_opt HICON* hicon) {
DBG_DPRINT(L"%s", L"cannot obtain instance");
return E_FAIL;
}

DWORD light = GetSystemLightTheme();
if (_controller->GetBlocked() == EngineController::BlockedKind::Blocked) {
*hicon = static_cast<HICON>(LoadImage(Globals::DllInstance, MAKEINTRESOURCE(IDI_ICONX), IMAGE_ICON, 16, 16, 0));
*hicon = static_cast<HICON>(LoadImage(Globals::DllInstance, MAKEINTRESOURCE(light ? IDI_ICONXL : IDI_ICONXD), IMAGE_ICON, 16, 16, 0));
} else if (_controller->IsEnabled()) {
*hicon = static_cast<HICON>(LoadImage(Globals::DllInstance, MAKEINTRESOURCE(IDI_ICONV), IMAGE_ICON, 16, 16, 0));
*hicon = static_cast<HICON>(LoadImage(Globals::DllInstance, MAKEINTRESOURCE(light ? IDI_ICONVL : IDI_ICONVD), IMAGE_ICON, 16, 16, 0));
} else {
*hicon = static_cast<HICON>(LoadImage(Globals::DllInstance, MAKEINTRESOURCE(IDI_ICONE), IMAGE_ICON, 16, 16, 0));
*hicon = static_cast<HICON>(LoadImage(Globals::DllInstance, MAKEINTRESOURCE(light ? IDI_ICONEL : IDI_ICONED), IMAGE_ICON, 16, 16, 0));
}
return *hicon ? S_OK : E_FAIL;
}
Expand Down
Binary file modified VietTypeATL/VietTypeATL.rc
Binary file not shown.
9 changes: 6 additions & 3 deletions VietTypeATL/VietTypeATL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,13 @@
<Midl Include="VietTypeATL.idl" />
</ItemGroup>
<ItemGroup>
<Image Include="resources\E.ico" />
<Image Include="resources\ED.ico" />
<Image Include="resources\EL.ico" />
<Image Include="resources\logo.ico" />
<Image Include="resources\V.ico" />
<Image Include="resources\X.ico" />
<Image Include="resources\VD.ico" />
<Image Include="resources\VL.ico" />
<Image Include="resources\XD.ico" />
<Image Include="resources\XL.ico" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Telex\Telex.vcxproj">
Expand Down
15 changes: 12 additions & 3 deletions VietTypeATL/VietTypeATL.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,22 @@
<Image Include="resources\logo.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="resources\E.ico">
<Image Include="resources\ED.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="resources\V.ico">
<Image Include="resources\EL.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="resources\X.ico">
<Image Include="resources\VD.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="resources\VL.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="resources\XD.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="resources\XL.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
Expand Down
Binary file modified VietTypeATL/resource.h
Binary file not shown.
Binary file added VietTypeATL/resources/ED.ico
Binary file not shown.
Binary file not shown.
Binary file added VietTypeATL/resources/VD.ico
Binary file not shown.
Binary file not shown.
Binary file added VietTypeATL/resources/XD.ico
Binary file not shown.
Binary file not shown.
Binary file modified VietTypeATL/resources/logo.ico
Binary file not shown.

0 comments on commit 68f94e9

Please sign in to comment.