aboutsummaryrefslogtreecommitdiff
path: root/c/window.h
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-09-07 00:40:26 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-09-07 00:40:26 +0200
commit2f7b69d6d4cf18ca9ca04d9a44aaa6871ce51160 (patch)
treed016a9456621b91ca902f0c1caf48468e899a553 /c/window.h
parent5b1a07607ba593050e37598f731f833b6faabee4 (diff)
downloadEpisodeBrowser-2f7b69d6d4cf18ca9ca04d9a44aaa6871ce51160.tar.gz
Improve error handling.
Diffstat (limited to 'c/window.h')
-rw-r--r--c/window.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/c/window.h b/c/window.h
index daf7202..9d247ec 100644
--- a/c/window.h
+++ b/c/window.h
@@ -15,7 +15,15 @@ struct Window
HWND hWnd;
HWND hWndFocus = nullptr;
HWND hWndStatus = nullptr;
- HMENU hMenuPopup = Require(GetSubMenu(Require(LoadMenuW(nullptr, MAKEINTRESOURCE(IDR_POPUPMENU))), 0));
+ const HMENU hMenuPopup = []()
+ {
+ HMENU hm;
+ if (!(hm = LoadMenuW(nullptr, MAKEINTRESOURCE(IDR_POPUPMENU))))
+ throw Err(WINDOWS, L"Context menu could not be loaded: %s");
+ if (!GetSubMenu(hm, 0))
+ throw Err(WINDOWS, L"Submenu could not be retrieved: %s");
+ return hm;
+ }();
/* File views. */
FileView<CfgA> fvCfg = FileView<CfgA>::Initialized(L"cfg.dat", 1);