aboutsummaryrefslogtreecommitdiff
path: root/c/main.c
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-03-02 18:31:34 +0100
committerJohn Ankarström <john@ankarstrom.se>2022-03-02 18:31:34 +0100
commitde437e83986d80f2fd49291969d154885ede7e9d (patch)
tree10c1974a2a0c5e68e5ba165a85fc7397e5a393a8 /c/main.c
parent196aeb5a981e184c9eb48a8215639252812f2608 (diff)
downloadEpisodeBrowser-de437e83986d80f2fd49291969d154885ede7e9d.tar.gz
Handle theme updates, improve focus handling
Diffstat (limited to 'c/main.c')
-rw-r--r--c/main.c43
1 files changed, 39 insertions, 4 deletions
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 <windows.h>
#include <commctrl.h>
+#include <uxtheme.h>
#include <SWI-Prolog.h>
#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);
+}