From f2509e8700f8b3083b185ce6e3e020f43bdf66e6 Mon Sep 17 00:00:00 2001 From: j v Date: Thu, 28 Jul 2022 22:55:56 -0700 Subject: [PATCH] Add About tab to settings dialog --- src/SettingsDialog.cpp | 44 +++++++++++++++++++++++++++++++++++++++++- src/resource.h | 5 +++++ src/resource.rc | 14 ++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/SettingsDialog.cpp b/src/SettingsDialog.cpp index f526946..11b95ea 100644 --- a/src/SettingsDialog.cpp +++ b/src/SettingsDialog.cpp @@ -108,6 +108,7 @@ INT_PTR CALLBACK generalProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar SetDlgItemText(hwnd, IDC_START_FOLDER_PATH, selected); PropSheet_Changed(GetParent(hwnd), hwnd); } + return TRUE; } else if (LOWORD(wParam) == IDC_EXPLORER_SETTINGS && HIWORD(wParam) == BN_CLICKED) { // https://docs.microsoft.com/en-us/windows/win32/shell/executing-control-panel-items#folder-options ShellExecute(nullptr, L"open", @@ -184,6 +185,7 @@ INT_PTR CALLBACK trayProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) settings::setTrayDirection(settings::TRAY_DOWN); else if (IsDlgButtonChecked(hwnd, IDC_TRAY_DIR_RIGHT)) settings::setTrayDirection(settings::TRAY_RIGHT); + SetWindowLongPtr(hwnd, DWLP_MSGRESULT, PSNRET_NOERROR); return TRUE; } else if (notif->code == PSN_HELP) { ShellExecute(nullptr, L"open", @@ -204,12 +206,14 @@ INT_PTR CALLBACK trayProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } else if (!checked && tray) { PostMessage(tray, WM_CLOSE, 0, 0); } + return TRUE; } else if (LOWORD(wParam) == IDC_TRAY_FOLDER_BROWSE && HIWORD(wParam) == BN_CLICKED) { CComHeapPtr selected; if (chooseFolder(GetParent(hwnd), selected)) { SetDlgItemText(hwnd, IDC_TRAY_FOLDER_PATH, selected); PropSheet_Changed(GetParent(hwnd), hwnd); } + return TRUE; } else if (LOWORD(wParam) == IDC_RESET_TRAY_POSITION && HIWORD(wParam) == BN_CLICKED) { settings::setTrayPosition(settings::DEFAULT_TRAY_POSITION); settings::setTraySize(settings::DEFAULT_TRAY_SIZE); @@ -220,6 +224,7 @@ INT_PTR CALLBACK trayProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (GetDlgItemText(hwnd, IDC_TRAY_FOLDER_PATH, path, _countof(path))) openTray(path); } + return TRUE; } else if (LOWORD(wParam) == IDC_TRAY_FOLDER_PATH && (HIWORD(wParam) == CBN_EDITCHANGE || HIWORD(wParam) == CBN_SELCHANGE)) { PropSheet_Changed(GetParent(hwnd), hwnd); @@ -236,13 +241,45 @@ INT_PTR CALLBACK trayProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } } +INT_PTR CALLBACK aboutProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { + switch (message) { + case WM_NOTIFY: { + NMHDR *notif = (NMHDR *)lParam; + if (notif->code == PSN_KILLACTIVE) { + SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE); + return TRUE; + } else if (notif->code == PSN_APPLY) { + SetWindowLongPtr(hwnd, DWLP_MSGRESULT, PSNRET_NOERROR); + return TRUE; + } + return FALSE; + } + case WM_COMMAND: + if (LOWORD(wParam) == IDC_UPDATES_LINK && HIWORD(wParam) == BN_CLICKED) { + ShellExecute(nullptr, L"open", L"https://github.com/vanjac/chromafile/releases", + nullptr, nullptr, SW_SHOWNORMAL); + return TRUE; + } else if (LOWORD(wParam) == IDC_HELP_LINK && HIWORD(wParam) == BN_CLICKED) { + ShellExecute(nullptr, L"open", L"https://github.com/vanjac/chromafile/wiki", + nullptr, nullptr, SW_SHOWNORMAL); + return TRUE; + } else if (LOWORD(wParam) == IDC_SOURCE_LINK && HIWORD(wParam) == BN_CLICKED) { + ShellExecute(nullptr, L"open", L"https://github.com/vanjac/chromafile", + nullptr, nullptr, SW_SHOWNORMAL); + return TRUE; + } + return FALSE; + } + return FALSE; +} + void openSettingsDialog() { if (settingsDialog) { SetActiveWindow(settingsDialog); return; } - PROPSHEETPAGE pages[2]; + PROPSHEETPAGE pages[3]; pages[0] = {sizeof(PROPSHEETPAGE)}; pages[0].dwFlags = PSP_HASHELP; @@ -256,6 +293,11 @@ void openSettingsDialog() { pages[1].pszTemplate = MAKEINTRESOURCE(IDD_SETTINGS_TRAY); pages[1].pfnDlgProc = trayProc; + pages[2] = {sizeof(PROPSHEETPAGE)}; + pages[2].hInstance = GetModuleHandle(nullptr); + pages[2].pszTemplate = MAKEINTRESOURCE(IDD_SETTINGS_ABOUT); + pages[2].pfnDlgProc = aboutProc; + PROPSHEETHEADER sheet = {sizeof(sheet)}; sheet.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_NOCONTEXTHELP | PSH_MODELESS; sheet.hInstance = GetModuleHandle(nullptr); diff --git a/src/resource.h b/src/resource.h index 5ab6c5d..46e53b7 100644 --- a/src/resource.h +++ b/src/resource.h @@ -51,6 +51,11 @@ #define IDC_TRAY_DIR_RIGHT 1007 #define IDC_RESET_TRAY_POSITION 1008 +#define IDD_SETTINGS_ABOUT 106 +#define IDC_UPDATES_LINK 1001 +#define IDC_HELP_LINK 1002 +#define IDC_SOURCE_LINK 1003 + #define IDS_SETTINGS_CAPTION 200 #define IDS_SETTINGS_COMMAND 201 #define IDS_REFRESH_COMMAND 202 diff --git a/src/resource.rc b/src/resource.rc index 4c8a45f..24a118d 100644 --- a/src/resource.rc +++ b/src/resource.rc @@ -99,6 +99,20 @@ IDD_SETTINGS_TRAY DIALOGEX PUSHBUTTON "R&eset tray position", IDC_RESET_TRAY_POSITION, 42, 135, 70, 14 } +IDD_SETTINGS_ABOUT DIALOGEX + 0, 0, 227, 215 // PROP_MED_CXDLG, PROP_MED_CYDLG + STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION + CAPTION "About" + FONT 8, "MS Shell Dlg", 400, 0, 0x0 { + ICON IDR_APP_ICON, -1, 7, 7, 0, 0 + LTEXT "chromafile", -1, 35, 7, 49, 8 + LTEXT "Version:", -1, 35, 15, 28, 8 + LTEXT CHROMAFILE_VERSION_STRING, -1, 70, 15, 28, 8 + PUSHBUTTON "Latest updates", IDC_UPDATES_LINK, 7, 28, 66, 14 + PUSHBUTTON "Help", IDC_HELP_LINK, 80, 28, 66, 14 + PUSHBUTTON "Source code", IDC_SOURCE_LINK, 153, 28, 66, 14 +} + STRINGTABLE { IDS_SETTINGS_CAPTION, "chromafile Settings" IDS_SETTINGS_COMMAND, "Settings"