aboutsummaryrefslogtreecommitdiff
path: root/c/main.c
diff options
context:
space:
mode:
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);
}