From 26f70ab37bee8ffd70b662ff999613c643215605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Thu, 14 Jul 2022 02:34:42 +0200 Subject: Initialize global variables in the right place. The rules for what messages are sent at window creation -- and in which order -- are neither intuitive or clear. WM_CREATE can NOT be relied upon to initialize global state required by handlers of other messages (such as WM_GETMINMAXINFO, which seems to be sent before WM_CREATE). Thus, the better solution is to initialize everything using a CBT hook before the window procedure is even run. Because CBTProc creates (child): windows of its own, though, one must be careful to only run the initialization once, which is done by checking g_hWnd. --- c/defs.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'c/defs.h') diff --git a/c/defs.h b/c/defs.h index 2fa2f06..14066a9 100644 --- a/c/defs.h +++ b/c/defs.h @@ -17,7 +17,7 @@ protected: WNDPROC m_prevProc; HWND m_hWnd; public: - void Create(HMENU, DWORD); + ListView(HMENU, DWORD); int Height(int); HWND HWnd(void) const; virtual void UpdateTheme(BOOL); @@ -25,12 +25,12 @@ public: }; /* episodelistview.cpp */ -class EpisodeListView: public ListView { +class EpisodeListView : public ListView { private: int m_iSort; LVITEM m_lviFocus; public: - void Create(void); + EpisodeListView(void); void DoSort(void); void EnsureFocusVisible(void); LRESULT HandleNotify(LPARAM); @@ -47,9 +47,9 @@ public: }; /* datalistview.cpp */ -class DataListView: public ListView { +class DataListView : public ListView { public: - void Create(void); + DataListView(void); void ShowEpisode(int); }; -- cgit v1.2.3