aboutsummaryrefslogtreecommitdiff
path: root/c/listview.c
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-02-15 16:29:59 +0100
committerJohn Ankarström <john@ankarstrom.se>2022-02-15 16:29:59 +0100
commit52fb337856497cb151081f3738e7cfa4bc2883bd (patch)
tree3309edbd0834bf90a5635b93038d1d088224e96e /c/listview.c
parent09ec144a99f1234a37d04854bdfb81485540be97 (diff)
downloadEpisodeBrowser-52fb337856497cb151081f3738e7cfa4bc2883bd.tar.gz
Rework list view code.
Diffstat (limited to 'c/listview.c')
-rw-r--r--c/listview.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/c/listview.c b/c/listview.c
new file mode 100644
index 0000000..362029f
--- /dev/null
+++ b/c/listview.c
@@ -0,0 +1,68 @@
+#include <windows.h>
+#include <commctrl.h>
+#include <uxtheme.h>
+
+#include "resource.h"
+#include "main.h"
+
+extern HFONT g_GUIFont;
+
+WNDPROC g_PrevLvProc;
+
+static LRESULT CALLBACK LvProc(HWND, UINT, WPARAM, LPARAM);
+
+HWND
+LvCreate(HWND hWnd, HMENU hMenu)
+{
+ HMODULE hModule;
+ HWND hListView;
+
+ hListView = CreateWindowEx(
+ 0,
+ WC_LISTVIEW,
+ TEXT(""),
+ WS_CHILD|WS_VISIBLE|WS_VSCROLL|LVS_REPORT,
+ 0, 0, 0, 0,
+ hWnd,
+ hMenu,
+ GetModuleHandle(NULL),
+ NULL
+ );
+
+ g_PrevLvProc = (WNDPROC)SetWindowLongPtr(hListView,
+ GWLP_WNDPROC, (LONG_PTR)LvProc);
+
+ ListView_SetExtendedListViewStyle(hListView,
+ LVS_EX_DOUBLEBUFFER);
+
+ SendMessage(hListView, WM_SETFONT,
+ (WPARAM)g_GUIFont, MAKELPARAM(FALSE, 0));
+
+ hModule = LoadLibrary(TEXT("uxtheme.dll"));
+ if (hModule && GetProcAddress(hModule, "SetWindowTheme")) {
+ ListView_SetExtendedListViewStyle(hListView,
+ LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER);
+ SendMessage(hListView, WM_CHANGEUISTATE,
+ MAKEWPARAM(UIS_SET, UISF_HIDEFOCUS), 0);
+ SetWindowTheme(hListView, TEXT("Explorer"), NULL);
+ }
+
+ return hListView;
+}
+
+LRESULT CALLBACK
+LvProc(HWND hListView, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch (uMsg) {
+ case WM_NOTIFY:
+ switch (((NMHDR *)lParam)->code) {
+ case HDN_ENDTRACK:
+ UpdateLayout(GetParent(hListView));
+ return TRUE;
+ }
+ break;
+ }
+
+ return CallWindowProc(g_PrevLvProc,
+ hListView, uMsg, wParam, lParam);
+}