From 2cd22c671c67deaf2c1fcb659e3262bf57552557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sat, 3 Sep 2022 01:15:01 +0200 Subject: Add Preferences dialog (WIP). --- c/main.cpp | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'c/main.cpp') diff --git a/c/main.cpp b/c/main.cpp index 82cda68..9e8cee3 100644 --- a/c/main.cpp +++ b/c/main.cpp @@ -8,7 +8,7 @@ #include "debug.h" #include "drag.h" #include "episodelistview.h" -#include "resource.h" +#include "res.h" #include "test.h" #include "util.h" #include "window.h" @@ -45,6 +45,8 @@ static void InitializeMainWindow(HWND) noexcept; static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); /* Handle messages to Help > About dialog. */ static INT_PTR CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM); +/* Handle messages to File > Preferences... dialog. */ +static INT_PTR CALLBACK PreferencesDlgProc(HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain( _In_ const HINSTANCE hInstance, @@ -200,6 +202,23 @@ INT_PTR CALLBACK AboutDlgProc(const HWND hWnd, const UINT uMsg, const WPARAM wPa } } +INT_PTR CALLBACK PreferencesDlgProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam, const LPARAM) +{ + switch (uMsg) { + case WM_CLOSE: + EndDialog(hWnd, IDOK); + return TRUE; + + case WM_COMMAND: + if (LOWORD(wParam) == IDOK) + EndDialog(hWnd, IDOK); + return TRUE; + + default: + return FALSE; + } +} + LRESULT CALLBACK Window::WndProc(const HWND hWnd, const UINT uMsg, const WPARAM wParam, const LPARAM lParam) { switch (uMsg) { @@ -296,11 +315,12 @@ LRESULT CALLBACK Window::WndProc(const HWND hWnd, const UINT uMsg, const WPARAM { /* Look up status bar tip for menu command. The tip * strings are stored in arrays, whose indices - * correspond to the IDM_ values (see resource.h). */ + * correspond to the IDM_ values (see res.h). */ const wchar_t* vTipMenu[] = { /*IDM_FILE_EXIT*/L"Close Episode Browser.", /*IDM_FILE_REFRESH*/L"Quickly refresh episode list.", + /*IDM_FILE_PREFERENCES*/L"Configure Episode Browser.", /*IDM_FILE_FETCH_DATA*/L"Fetch episode data from the web (may take a few seconds).", /*IDM_FILE_FETCH_SCREENWRITERS*/L"Fetch screenwriters from the web (may take a minute).", /*IDM_FILE_FETCH_CANCEL*/L"Stop fetching data from the web.", @@ -375,6 +395,14 @@ void Window::HandleMainMenu(const HWND hWnd, const WORD command) elv.Update(); break; + case IDM_FILE_PREFERENCES: + DialogBox( + GetModuleHandle(nullptr), + MAKEINTRESOURCE(IDD_PREFERENCES), + hWnd, + PreferencesDlgProc); + break; + case IDM_FILE_FETCH_DATA: { WaitFor(*this, FetchData); -- cgit v1.2.3