aboutsummaryrefslogtreecommitdiff
path: root/c/listview.cpp
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-07-17 18:07:40 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-07-17 18:07:40 +0200
commite1906e8f45b732d83aca0935c59852c7aa64def9 (patch)
tree9456f5629d68c1bae7251cb44e2b01cd49532565 /c/listview.cpp
parentbb22bc506676fd268ded3b3d6c7b7acea5dc2db9 (diff)
downloadEpisodeBrowser-e1906e8f45b732d83aca0935c59852c7aa64def9.tar.gz
Make ListView hWnd public.
A getter offers encapsulation, but it is also less transparent in a sense. Thinking of ListView as a struct, it is natural to expose hWnd as a public member variable.
Diffstat (limited to 'c/listview.cpp')
-rw-r--r--c/listview.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/c/listview.cpp b/c/listview.cpp
index f70abe5..6c0185d 100644
--- a/c/listview.cpp
+++ b/c/listview.cpp
@@ -13,7 +13,7 @@ ListView::ListView(const HWND hWndParent, const HMENU hMenu, const DWORD dwStyle
{
m_hWndParent = hWndParent;
m_bHeader = !(dwStyle & LVS_NOCOLUMNHEADER);
- m_hWnd = CreateWindowEx(
+ hWnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
WC_LISTVIEW,
TEXT(""),
@@ -21,12 +21,12 @@ ListView::ListView(const HWND hWndParent, const HMENU hMenu, const DWORD dwStyle
0, 0, 0, 0,
m_hWndParent, hMenu, GetModuleHandle(NULL), this
);
- if (SetProp(m_hWnd, TEXT("this"), (HANDLE)this))
- m_prevProc = (WNDPROC)SetWindowLongPtr(m_hWnd,
+ if (SetProp(hWnd, TEXT("this"), (HANDLE)this))
+ m_prevProc = (WNDPROC)SetWindowLongPtr(hWnd,
GWLP_WNDPROC, (LONG_PTR)::WndProc);
- ListView_SetExtendedListViewStyle(m_hWnd, LVS_EX_FULLROWSELECT);
- SendMessage(m_hWnd, WM_SETFONT, (WPARAM)g_hfNormal, MAKELPARAM(FALSE, 0));
+ ListView_SetExtendedListViewStyle(hWnd, LVS_EX_FULLROWSELECT);
+ SendMessage(hWnd, WM_SETFONT, (WPARAM)g_hfNormal, MAKELPARAM(FALSE, 0));
}
/* Naively calculate height of list view. */
@@ -34,15 +34,10 @@ int ListView::Height(int bHeader)
{
if (bHeader == -1)
bHeader = m_bHeader;
- const int iCount = ListView_GetItemCount(m_hWnd);
+ const int iCount = ListView_GetItemCount(hWnd);
return iCount? Dpi(bHeader? 27: 4)+iCount*Dpi(19): 0;
}
-HWND ListView::Handle() const
-{
- return m_hWnd;
-}
-
void ListView::UpdateTheme(const BOOL bThemeActive)
{
DWORD dwStyle;
@@ -62,13 +57,13 @@ void ListView::UpdateTheme(const BOOL bThemeActive)
}
/* Use modern "Explorer" theme. */
- SetWindowTheme(m_hWnd, tszTheme, NULL);
+ SetWindowTheme(hWnd, tszTheme, NULL);
/* The modern theme requires double buffering. */
- ListView_SetExtendedListViewStyleEx(m_hWnd, LVS_EX_DOUBLEBUFFER, dwStyle);
+ ListView_SetExtendedListViewStyleEx(hWnd, LVS_EX_DOUBLEBUFFER, dwStyle);
/* Hide focus rectangles. */
- SendMessage(m_hWnd, WM_UPDATEUISTATE, MAKEWPARAM(wAction, UISF_HIDEFOCUS), 0);
+ SendMessage(hWnd, WM_UPDATEUISTATE, MAKEWPARAM(wAction, UISF_HIDEFOCUS), 0);
}
LRESULT CALLBACK ListView::WndProc(const HWND hWnd, const UINT uMsg,