diff options
author | John Ankarström <john@ankarstrom.se> | 2022-04-02 04:00:54 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-04-02 04:00:54 +0200 |
commit | e9978f8d1c1acd2e51a64ad5dbe936417fd094d5 (patch) | |
tree | 9440e5b7c30e84a3b942e10ce332b1a2413723ca | |
parent | df61ed83d8511f3ecb26d5af119df619b430b2f9 (diff) | |
download | EpisodeBrowser-e9978f8d1c1acd2e51a64ad5dbe936417fd094d5.tar.gz |
Clean up UpdateTheme.
-rw-r--r-- | c/defs.h | 1 | ||||
-rw-r--r-- | c/listview.c | 10 | ||||
-rw-r--r-- | c/main.c | 36 |
3 files changed, 26 insertions, 21 deletions
@@ -14,7 +14,6 @@ void UpdateLayout(); /* listview.c */ HWND LvCreate(HMENU); int LvHeight(HWND); -void LvSetTheme(HWND, int); /* episodelistview.c */ HWND ElvCreate(); diff --git a/c/listview.c b/c/listview.c index a578c61..8a96219 100644 --- a/c/listview.c +++ b/c/listview.c @@ -77,13 +77,3 @@ LvHeight(HWND hLv) return iCount? Dpi(27)+iCount*Dpi(19): 0; } -/* Enable/disable non-classic list view theme. */ -void -LvSetTheme(HWND hLv, int bUseTheme) -{ - ListView_SetExtendedListViewStyleEx(hLv, - LVS_EX_DOUBLEBUFFER, bUseTheme ? LVS_EX_DOUBLEBUFFER : 0); - SendMessage(hLv, WM_UPDATEUISTATE, - MAKEWPARAM(bUseTheme ? UIS_SET : UIS_CLEAR, UISF_HIDEFOCUS), 0); - SetWindowTheme(hLv, bUseTheme ? TEXT("Explorer") : NULL, NULL); -} @@ -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); } |