From 90c7bc237c9cf964c16f0cb48c308a92a8193a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Fri, 2 Sep 2022 02:11:49 +0200 Subject: Use global Window object. This makes it easier to control initialization and maintain RAII. --- c/listview.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'c/listview.cpp') diff --git a/c/listview.cpp b/c/listview.cpp index 41f68a7..6074707 100644 --- a/c/listview.cpp +++ b/c/listview.cpp @@ -3,24 +3,24 @@ #include "listview.h" #include "layout.h" +#include "main.h" #include "win.h" /* Actual window procedure for all list views, which calls the * appropriate WndProc member function. */ static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); -ListView::ListView(const HWND hWndParent, const HMENU hMenu, const DWORD dwStyle) +ListView::ListView(Window& parent, const HMENU hMenu, const DWORD dwStyle) : parent(parent) { extern HFONT g_hfNormal; - m_hWndParent = hWndParent; hWnd = Require(CreateWindowExW( WS_EX_CLIENTEDGE, WC_LISTVIEW, L"", dwStyle|WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP|LVS_REPORT|LVS_SHOWSELALWAYS, 0, 0, 0, 0, - hWndParent, hMenu, GetModuleHandle(nullptr), this)); + parent.hWnd, hMenu, GetModuleHandle(nullptr), this)); m_proc0 = reinterpret_cast(SetWindowLongPtr( hWnd, GWLP_WNDPROC, reinterpret_cast(::WndProc))); @@ -41,7 +41,7 @@ void ListView::UpdateTheme(const bool bThemeActive) { const wchar_t* theme; WORD action; - extern BOOL (*SetWindowTheme)(HWND, const wchar_t*, const wchar_t*); + extern HRESULT (__stdcall *SetWindowTheme)(HWND, const wchar_t*, const wchar_t*); if (!SetWindowTheme) return; if (bThemeActive) { @@ -62,7 +62,6 @@ void ListView::UpdateTheme(const bool bThemeActive) LRESULT CALLBACK ListView::WndProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam, const LPARAM lParam) { - extern DlvDragger g_dragDlv; switch (uMsg) { case WM_NOTIFY: switch (reinterpret_cast(lParam)->code) { @@ -73,7 +72,7 @@ LRESULT CALLBACK ListView::WndProc(const HWND hWnd, const UINT uMsg, break; case WM_LBUTTONDOWN: case WM_NCLBUTTONDOWN: - if (g_dragDlv.HandleLButtonDown()) + if (parent.dragDlv.HandleLButtonDown()) return 0; break; } -- cgit v1.2.3