aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-07-16 01:00:20 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-07-16 01:00:20 +0200
commit84c3dd3587e219caa80adc2070f0e9fe004c27bc (patch)
treee73b7367e8a44dba66498ae7dc244cf49b269897
parent70928745565b01f3fae0e32ea007266aa2e1edc5 (diff)
downloadEpisodeBrowser-84c3dd3587e219caa80adc2070f0e9fe004c27bc.tar.gz
Add m_hWndParent to ListView.
This avoids g_hWnd.
-rw-r--r--c/datalistview.cpp3
-rw-r--r--c/datalistview.h2
-rw-r--r--c/episodelistview.cpp6
-rw-r--r--c/episodelistview.h2
-rw-r--r--c/listview.cpp7
-rw-r--r--c/listview.h3
-rw-r--r--c/main.cpp4
7 files changed, 14 insertions, 13 deletions
diff --git a/c/datalistview.cpp b/c/datalistview.cpp
index b730993..2920c0c 100644
--- a/c/datalistview.cpp
+++ b/c/datalistview.cpp
@@ -12,7 +12,8 @@
extern EpisodeListView *g_lpElv;
-DataListView::DataListView() : ListView((HMENU)IDC_DATALISTVIEW, LVS_NOCOLUMNHEADER)
+DataListView::DataListView(HWND hWndParent)
+ : ListView(hWndParent, (HMENU)IDC_DATALISTVIEW, LVS_NOCOLUMNHEADER)
{
LVCOLUMN lvc;
diff --git a/c/datalistview.h b/c/datalistview.h
index 011f067..7dd0447 100644
--- a/c/datalistview.h
+++ b/c/datalistview.h
@@ -5,7 +5,7 @@
struct DataListView : public ListView
{
- DataListView(void);
+ DataListView(HWND);
void ShowEpisode(int);
};
diff --git a/c/episodelistview.cpp b/c/episodelistview.cpp
index a126649..1a41986 100644
--- a/c/episodelistview.cpp
+++ b/c/episodelistview.cpp
@@ -13,7 +13,8 @@
extern DataListView *g_lpDlv;
int CALLBACK ElvSort(LPARAM, LPARAM, LPARAM);
-EpisodeListView::EpisodeListView() : ListView((HMENU)IDC_EPISODELISTVIEW, 0)
+EpisodeListView::EpisodeListView(HWND hWndParent)
+ : ListView(hWndParent, (HMENU)IDC_EPISODELISTVIEW, 0)
{
LVCOLUMN lvc;
@@ -129,12 +130,11 @@ LRESULT EpisodeListView::HandleNotify(LPARAM lParam)
}
case NM_RCLICK:
{
- extern HWND g_hWnd;
extern HMENU g_hPopupMenu;
DWORD dwPos = GetMessagePos();
TrackPopupMenu(g_hPopupMenu, TPM_RIGHTBUTTON,
LOWORD(dwPos), HIWORD(dwPos), 0,
- g_hWnd, NULL);
+ m_hWndParent, NULL);
break;
}
}
diff --git a/c/episodelistview.h b/c/episodelistview.h
index 8befc14..141bf84 100644
--- a/c/episodelistview.h
+++ b/c/episodelistview.h
@@ -8,7 +8,7 @@
struct EpisodeListView : public ListView
{
- EpisodeListView(void);
+ EpisodeListView(HWND);
void DoSort(void);
void EnsureFocusVisible(void);
LRESULT HandleNotify(LPARAM);
diff --git a/c/listview.cpp b/c/listview.cpp
index 4e9d754..0f4cbc1 100644
--- a/c/listview.cpp
+++ b/c/listview.cpp
@@ -7,20 +7,19 @@
#include "main.h"
extern HFONT g_hfNormal;
-extern HWND g_hWnd;
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
-ListView::ListView(HMENU hMenu, DWORD dwStyle)
+ListView::ListView(HWND hWndParent, HMENU hMenu, DWORD dwStyle)
{
+ m_hWndParent = hWndParent;
m_bHeader = !(dwStyle & LVS_NOCOLUMNHEADER);
-
m_hWnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
WC_LISTVIEW,
TEXT(""),
dwStyle|WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP|LVS_REPORT|LVS_SHOWSELALWAYS,
0, 0, 0, 0,
- g_hWnd, hMenu, GetModuleHandle(NULL), this
+ m_hWndParent, hMenu, GetModuleHandle(NULL), this
);
if (SetProp(m_hWnd, TEXT("this"), (HANDLE)this))
diff --git a/c/listview.h b/c/listview.h
index 369c4ec..cf5dc26 100644
--- a/c/listview.h
+++ b/c/listview.h
@@ -5,7 +5,7 @@
struct ListView
{
- ListView(HMENU, DWORD);
+ ListView(HWND, HMENU, DWORD);
int Height(int = -1);
HWND HWnd(void) const;
virtual void UpdateTheme(BOOL);
@@ -14,6 +14,7 @@ protected:
int m_bHeader = 1;
WNDPROC m_prevProc;
HWND m_hWnd;
+ HWND m_hWndParent;
};
#endif
diff --git a/c/main.cpp b/c/main.cpp
index cbfb8f1..6ed7ac1 100644
--- a/c/main.cpp
+++ b/c/main.cpp
@@ -169,8 +169,8 @@ static LRESULT CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam)
g_iDPI = GetDpiForWindow(g_hWnd);
/* Create child windows. */
- g_lpDlv = new DataListView;
- g_lpElv = new EpisodeListView;
+ g_lpDlv = new DataListView(g_hWnd);
+ g_lpElv = new EpisodeListView(g_hWnd);
/* Get saved view settings. */
char *sz;