aboutsummaryrefslogtreecommitdiff
path: root/c
diff options
context:
space:
mode:
Diffstat (limited to 'c')
-rw-r--r--c/defs.h1
-rw-r--r--c/episodelistview.c3
-rw-r--r--c/listview.c25
-rw-r--r--c/main.c43
4 files changed, 56 insertions, 16 deletions
diff --git a/c/defs.h b/c/defs.h
index ea8c4c1..f5feb3e 100644
--- a/c/defs.h
+++ b/c/defs.h
@@ -12,6 +12,7 @@ void UpdateLayout();
/* listview.c */
HWND LvCreate(HMENU);
+void LvSetTheme(HWND, int);
/* episodelistview.c */
HWND ElvCreate();
diff --git a/c/episodelistview.c b/c/episodelistview.c
index c2d937b..8ca64d5 100644
--- a/c/episodelistview.c
+++ b/c/episodelistview.c
@@ -132,7 +132,8 @@ ElvSelectRecent()
if (iItem > 5)
ElvSetTop(iItem-5);
- ListView_SetItemState(HElv, iItem, LVIS_SELECTED, LVIS_SELECTED);
+ ListView_SetItemState(HElv, iItem,
+ LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
LpLviElvSelection->iItem = iItem;
LpLviElvSelection->lParam = iEpisode;
ElvUpdateName(LpLviElvSelection);
diff --git a/c/listview.c b/c/listview.c
index 48b61e1..7039e89 100644
--- a/c/listview.c
+++ b/c/listview.c
@@ -13,14 +13,14 @@ static LRESULT CALLBACK LvProc(HWND, UINT, WPARAM, LPARAM);
HWND
LvCreate(HMENU hMenu)
{
- HMODULE hModule;
HWND hLv;
hLv = CreateWindowEx(
WS_EX_CLIENTEDGE,
WC_LISTVIEW,
TEXT(""),
- WS_CHILD|WS_VISIBLE|WS_VSCROLL|LVS_REPORT|LVS_NOSORTHEADER,
+ WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP
+ |LVS_REPORT|LVS_NOSORTHEADER,
0, 0, 0, 0,
HWnd, hMenu, GetModuleHandle(NULL), NULL
);
@@ -33,15 +33,6 @@ LvCreate(HMENU hMenu)
SendMessage(hLv, WM_SETFONT,
(WPARAM)HfNormal, MAKELPARAM(FALSE, 0));
- hModule = LoadLibrary(TEXT("uxtheme.dll"));
- if (hModule && GetProcAddress(hModule, "SetWindowTheme")) {
- ListView_SetExtendedListViewStyleEx(hLv,
- LVS_EX_DOUBLEBUFFER, LVS_EX_DOUBLEBUFFER);
- SendMessage(hLv, WM_CHANGEUISTATE,
- MAKEWPARAM(UIS_SET, UISF_HIDEFOCUS), 0);
- SetWindowTheme(hLv, TEXT("Explorer"), NULL);
- }
-
return hLv;
}
@@ -60,3 +51,15 @@ LvProc(HWND hLv, UINT uMsg, WPARAM wParam, LPARAM lParam)
return CallWindowProc(LvPrevProc, hLv, uMsg, wParam, lParam);
}
+
+void
+LvSetTheme(HWND hLv, int bUseTheme)
+{
+ ListView_SetExtendedListViewStyleEx(hLv,
+ LVS_EX_DOUBLEBUFFER,
+ bUseTheme ? LVS_EX_DOUBLEBUFFER : 0);
+ SendMessage(hLv, WM_CHANGEUISTATE,
+ MAKEWPARAM(bUseTheme ? UIS_SET : UIS_CLEAR,
+ UISF_HIDEFOCUS), 0);
+ SetWindowTheme(hLv, bUseTheme ? TEXT("Explorer") : NULL, NULL);
+}
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);
+}