From 5fb8df682831045c4619b65403c4a24d7583d2e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Wed, 3 Aug 2022 19:11:15 +0200 Subject: Remove m_bHeader from ListView. If it is relevant to add height for a header for a given list view, it is better to override Height and do it there. --- c/datalistview.cpp | 4 ++-- c/datalistview.h | 2 +- c/listview.cpp | 15 +++++---------- c/listview.h | 3 +-- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/c/datalistview.cpp b/c/datalistview.cpp index cdc6dfb..e6cc6ca 100644 --- a/c/datalistview.cpp +++ b/c/datalistview.cpp @@ -30,9 +30,9 @@ DataListView::DataListView(const HWND hWndParent) ListView_InsertColumn(hWnd, DLVSIVALUE, &lvc); } -int DataListView::Height(int bHeader) +int DataListView::Height() { - return m_height? m_height: ListView::Height(bHeader); + return m_height? m_height: ListView::Height(); } void DataListView::ResizeColumns(int w) diff --git a/c/datalistview.h b/c/datalistview.h index c094d0e..5a4c7ca 100644 --- a/c/datalistview.h +++ b/c/datalistview.h @@ -9,7 +9,7 @@ struct DataListView : public ListView { DataListView(HWND hWndParent); - int Height(int bHeader = -1) override; + int Height() override; void ResizeColumns(int w) override; void SetHeight(int h); void ShowEpisode(int iEpisode); diff --git a/c/listview.cpp b/c/listview.cpp index c2f5593..e5d22b2 100644 --- a/c/listview.cpp +++ b/c/listview.cpp @@ -11,19 +11,16 @@ static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); ListView::ListView(const HWND hWndParent, const HMENU hMenu, const DWORD dwStyle) { m_hWndParent = hWndParent; - m_bHeader = !(dwStyle & LVS_NOCOLUMNHEADER); hWnd = require(CreateWindowEx( WS_EX_CLIENTEDGE, WC_LISTVIEW, L"", dwStyle|WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP|LVS_REPORT|LVS_SHOWSELALWAYS, 0, 0, 0, 0, - m_hWndParent, hMenu, GetModuleHandle(NULL), this)); - - if (require(SetProp(hWnd, L"this", (HANDLE)this))) - m_proc0 = (WNDPROC)SetWindowLongPtr(hWnd, - GWLP_WNDPROC, (LONG_PTR)::WndProc); + hWndParent, hMenu, GetModuleHandle(NULL), this)); + m_proc0 = (WNDPROC)SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)::WndProc); + require(SetProp(hWnd, L"this", (HANDLE)this)); ListView_SetExtendedListViewStyle(hWnd, LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER); SendMessage(hWnd, WM_SETFONT, (WPARAM)g_hfNormal, MAKELPARAM(FALSE, 0)); } @@ -37,12 +34,10 @@ bool ListView::FindNextItem(LVITEM* const lvi, const LPARAM lParam) } /* Naively calculate height of list view. */ -int ListView::Height(int bHeader) +int ListView::Height() { - if (bHeader == -1) - bHeader = m_bHeader; const int cItem = ListView_GetItemCount(hWnd); - return cItem? Dpi(bHeader? 27: 4)+cItem*Dpi(19): 0; + return Dpi(4)+cItem*Dpi(19); } void ListView::ResizeColumns(int) {} diff --git a/c/listview.h b/c/listview.h index c812cd8..1de6cc1 100644 --- a/c/listview.h +++ b/c/listview.h @@ -10,12 +10,11 @@ struct ListView ListView(HWND hWndParent, HMENU hMenu, DWORD dwStyle); bool FindNextItem(LVITEM* lvi, LPARAM lParam); - virtual int Height(int bHeader = -1); + virtual int Height(); virtual void ResizeColumns(int w); virtual void UpdateTheme(BOOL bThemeActive); virtual LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); protected: - int m_bHeader = 1; WNDPROC m_proc0; HWND m_hWndParent; }; -- cgit v1.2.3