diff --git a/src/modules/CropAndLock/CropAndLock/CropAndLock.vcxproj b/src/modules/CropAndLock/CropAndLock/CropAndLock.vcxproj
index f3ce71829f..859bbc3116 100644
--- a/src/modules/CropAndLock/CropAndLock/CropAndLock.vcxproj
+++ b/src/modules/CropAndLock/CropAndLock/CropAndLock.vcxproj
@@ -154,6 +154,9 @@
{8f021b46-362b-485c-bfba-ccf83e820cbd}
+
+ {98537082-0fdb-40de-abd8-0dc5a4269bab}
+
diff --git a/src/modules/CropAndLock/CropAndLock/main.cpp b/src/modules/CropAndLock/CropAndLock/main.cpp
index 79d26fc8c1..5aeea262a4 100644
--- a/src/modules/CropAndLock/CropAndLock/main.cpp
+++ b/src/modules/CropAndLock/CropAndLock/main.cpp
@@ -17,6 +17,9 @@
#include
+#include
+#include
+
#pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
namespace winrt
@@ -35,6 +38,23 @@ namespace util
const std::wstring instanceMutexName = L"Local\\PowerToys_CropAndLock_InstanceMutex";
bool m_running = true;
+// Theming
+ThemeListener theme_listener{};
+// Keep a list of our cropped windows
+std::vector> croppedWindows;
+
+void handleTheme()
+{
+ auto theme = theme_listener.AppTheme;
+ auto isDark = theme == Theme::Dark;
+ Logger::info(L"Theme is now {}", isDark ? L"Dark" : L"Light");
+ for (auto&& croppedWindow : croppedWindows)
+ {
+ ThemeHelpers::SetImmersiveDarkMode(croppedWindow->Handle(), isDark);
+ }
+}
+
+
int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR lpCmdLine, _In_ int)
{
// Initialize COM
@@ -42,6 +62,8 @@ int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR lpCmdLine, _I
Trace::CropAndLock::RegisterProvider();
+ theme_listener.AddChangedHandler(handleTheme);
+
Shared::Trace::ETWTrace trace;
trace.UpdateState(true);
@@ -107,8 +129,6 @@ int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR lpCmdLine, _I
// Create our overlay window
std::unique_ptr overlayWindow;
- // Keep a list of our cropped windows
- std::vector> croppedWindows;
// Handles and thread for the events sent from runner
HANDLE m_reparent_event_handle;
@@ -167,6 +187,7 @@ int WINAPI wWinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ PWSTR lpCmdLine, _I
croppedWindow->CropAndLock(targetWindow, cropRect);
croppedWindow->OnClosed(removeWindowCallback);
croppedWindows.push_back(croppedWindow);
+ handleTheme();
};
overlayWindow.reset();