From de437e83986d80f2fd49291969d154885ede7e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Wed, 2 Mar 2022 18:31:34 +0100 Subject: Handle theme updates, improve focus handling --- c/main.c | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'c/main.c') diff --git a/c/main.c b/c/main.c index c3e1be1..e0e4858 100644 --- a/c/main.c +++ b/c/main.c @@ -1,5 +1,6 @@ #include #include +#include #include #include "resource.h" @@ -12,7 +13,8 @@ HWND HWnd; static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); static INT_PTR CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM); static int Attach(void); -static void SetupFonts(); +static void SetupFonts(void); +static void UpdateTheme(void); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, @@ -73,6 +75,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, ShowWindow(hWnd, nCmdShow); while (GetMessage(&msg, NULL, 0, 0) > 0) { + if (IsDialogMessage(hWnd, &msg)) continue; TranslateMessage(&msg); DispatchMessage(&msg); } @@ -98,14 +101,28 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) UpdateLayout(); break; case WM_CREATE: + { + extern HWND HElv; HWnd = hWnd; DlvCreate(); ElvCreate(); + UpdateTheme(); + break; + } + case WM_THEMECHANGED: + UpdateTheme(); break; case WM_ACTIVATE: - if (wParam != WA_INACTIVE) { - fid_t f; - term_t t; + switch (wParam) { + fid_t f; + term_t t; + extern HWND HElv; + case WA_INACTIVE: + break; + case WA_ACTIVE: + SetFocus(HElv); + /* no break */ + case WA_CLICKACTIVE: F(f); t = T(0); P("track_episodes","update_tracked_episodes",0,t); @@ -282,3 +299,21 @@ UpdateLayout() ListView_SetColumnWidth(hElv, 1, rc.right-cxColumn-cxVScroll-4); } + +void +UpdateTheme() +{ + int bThemeActive; + extern HWND HElv, HDlv; + static int bTheming = -1; + + if (bTheming == -1) { + HMODULE hModule; + hModule = LoadLibrary(TEXT("uxtheme.dll")); + bTheming = hModule && GetProcAddress(hModule, "SetWindowTheme"); + } + if (!bTheming) return; + bThemeActive = IsThemeActive(); + LvSetTheme(HElv, bThemeActive); + LvSetTheme(HDlv, bThemeActive); +} -- cgit v1.2.3