aboutsummaryrefslogtreecommitdiff
path: root/c/main.c
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-04-02 04:00:54 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-04-02 04:00:54 +0200
commite9978f8d1c1acd2e51a64ad5dbe936417fd094d5 (patch)
tree9440e5b7c30e84a3b942e10ce332b1a2413723ca /c/main.c
parentdf61ed83d8511f3ecb26d5af119df619b430b2f9 (diff)
downloadEpisodeBrowser-e9978f8d1c1acd2e51a64ad5dbe936417fd094d5.tar.gz
Clean up UpdateTheme.
Diffstat (limited to 'c/main.c')
-rw-r--r--c/main.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/c/main.c b/c/main.c
index 6f8b834..3906383 100644
--- a/c/main.c
+++ b/c/main.c
@@ -326,22 +326,38 @@ UpdateLayout()
void
UpdateTheme()
{
- int bThemeActive;
+ DWORD dwStyle;
+ LPTSTR tszTheme;
+ WORD wAction;
extern HWND HElv, HDlv;
static int bThemes = -1;
- switch (bThemes) {
- case 0:
- return;
- case -1:
- {
+ if (bThemes == -1) {
HMODULE hModule;
hModule = LoadLibrary(TEXT("uxtheme.dll"));
bThemes = hModule && GetProcAddress(hModule,"SetWindowTheme");
- }
+ FreeLibrary(hModule);
}
+ if (!bThemes) return;
+
+ if (IsThemeActive()) {
+ dwStyle = LVS_EX_DOUBLEBUFFER;
+ tszTheme = TEXT("Explorer");
+ wAction = UIS_SET;
+ } else {
+ dwStyle = 0;
+ tszTheme = NULL;
+ wAction = UIS_CLEAR;
+ }
+
+ /* Use modern "Explorer" theme. */
+ SetWindowTheme(HElv, tszTheme, NULL);
+ SetWindowTheme(HDlv, tszTheme, NULL);
+
+ /* The modern theme requires double buffering. */
+ ListView_SetExtendedListViewStyleEx(HElv, LVS_EX_DOUBLEBUFFER, dwStyle);
+ ListView_SetExtendedListViewStyleEx(HDlv, LVS_EX_DOUBLEBUFFER, dwStyle);
- bThemeActive = IsThemeActive();
- LvSetTheme(HElv, bThemeActive);
- LvSetTheme(HDlv, bThemeActive);
+ /* Hide focus rectangles. */
+ SendMessage(HWnd, WM_UPDATEUISTATE, MAKEWPARAM(wAction, UISF_HIDEFOCUS), 0);
}