diff options
author | John Ankarström <john@ankarstrom.se> | 2022-09-07 00:40:26 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-09-07 00:40:26 +0200 |
commit | 2f7b69d6d4cf18ca9ca04d9a44aaa6871ce51160 (patch) | |
tree | d016a9456621b91ca902f0c1caf48468e899a553 /c/listview.cpp | |
parent | 5b1a07607ba593050e37598f731f833b6faabee4 (diff) | |
download | EpisodeBrowser-2f7b69d6d4cf18ca9ca04d9a44aaa6871ce51160.tar.gz |
Improve error handling.
Diffstat (limited to 'c/listview.cpp')
-rw-r--r-- | c/listview.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/c/listview.cpp b/c/listview.cpp index b638f7b..0615ed0 100644 --- a/c/listview.cpp +++ b/c/listview.cpp @@ -2,6 +2,7 @@ #include <commctrl.h> #include "drag.h" +#include "err.h" #include "listview.h" #include "win32.h" #include "window.h" @@ -14,17 +15,19 @@ ListView::ListView(Window& parent, const HMENU hMenu, const DWORD dwStyle) : par { extern HFONT g_hfNormal; - hWnd = Require(CreateWindowExW( + if (!(hWnd = CreateWindowExW( WS_EX_CLIENTEDGE, WC_LISTVIEW, L"", dwStyle|WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_TABSTOP|LVS_REPORT|LVS_SHOWSELALWAYS, 0, 0, 0, 0, - parent.hWnd, hMenu, GetModuleHandle(nullptr), this)); + parent.hWnd, hMenu, GetModuleHandle(nullptr), this))) + throw Err(WINDOWS, L"List view could not be created: %s"); m_proc0 = reinterpret_cast<WNDPROC>(SetWindowLongPtr( - hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(::WndProc))); + hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(Except<::WndProc>))); - Require(SetPropW(hWnd, L"this", reinterpret_cast<HANDLE>(this))); + if (!SetPropW(hWnd, L"this", reinterpret_cast<HANDLE>(this))) + throw Err(WINDOWS, L"List view property could not be set: %s"); ListView_SetExtendedListViewStyle(hWnd, LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER); SendMessageW(hWnd, WM_SETFONT, reinterpret_cast<WPARAM>(g_hfNormal), MAKELPARAM(FALSE, 0)); } |