diff --git a/src/AboutDlg.cpp b/src/AboutDlg.cpp index ed740f16..8e6a0079 100644 --- a/src/AboutDlg.cpp +++ b/src/AboutDlg.cpp @@ -1,6 +1,6 @@ // This file is part of BowPad. // -// Copyright (C) 2013, 2015-2017, 2020-2022 - Stefan Kueng +// Copyright (C) 2013, 2015-2017, 2020-2022, 2024 - Stefan Kueng // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -21,8 +21,11 @@ #include "version.h" #include "Theme.h" #include "ResString.h" +#include "../ext/sktoolslib/StringUtils.h" + #include #include +#include CAboutDlg::CAboutDlg(HWND hParent) : m_hParent(hParent) @@ -45,13 +48,12 @@ LRESULT CAboutDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam CTheme::Instance().SetThemeForDialog(*this, CTheme::Instance().IsDarkTheme()); // initialize the controls m_link.ConvertStaticToHyperlink(hwndDlg, IDC_WEBLINK, L"http://tools.stefankueng.com"); - wchar_t verbuf[1024] = {0}; #ifdef _WIN64 - swprintf_s(verbuf, _countof(verbuf), L"BowPad version %d.%d.%d.%d (64-bit)", BP_VERMAJOR, BP_VERMINOR, BP_VERMICRO, BP_VERBUILD); + m_version = std::format(L"BowPad version {}.{}.{}.{} (64-bit)", BP_VERMAJOR, BP_VERMINOR, BP_VERMICRO, BP_VERBUILD); #else - swprintf_s(verbuf, _countof(verbuf), L"BowPad version %d.%d.%d.%d", BP_VERMAJOR, BP_VERMINOR, BP_VERMICRO, BP_VERBUILD); + m_version = std::format(L"BowPad version {}.{}.{}.{}", BP_VERMAJOR, BP_VERMINOR, BP_VERMICRO, BP_VERBUILD); #endif - SetDlgItemText(hwndDlg, IDC_VERSIONLABEL, verbuf); + SetDlgItemText(hwndDlg, IDC_VERSIONLABEL, m_version.c_str()); SetFocus(GetDlgItem(hwndDlg, IDOK)); } return FALSE; @@ -88,3 +90,17 @@ LRESULT CAboutDlg::DoCommand(int id) } return 1; } + +bool CAboutDlg::PreTranslateMessage(MSG* pMsg) +{ + if (pMsg->message == WM_KEYDOWN) + { + auto bCtrl = (GetKeyState(VK_CONTROL) & 0x8000) != 0; + if (bCtrl && pMsg->wParam == 'C') + { + WriteAsciiStringToClipboard(m_version.c_str(), m_hwnd); + return true; + } + } + return false; +} diff --git a/src/AboutDlg.h b/src/AboutDlg.h index 46e5997a..350e7103 100644 --- a/src/AboutDlg.h +++ b/src/AboutDlg.h @@ -1,6 +1,6 @@ // This file is part of BowPad. // -// Copyright (C) 2013, 2016, 2021 - Stefan Kueng +// Copyright (C) 2013, 2016, 2021, 2024 - Stefan Kueng // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -27,13 +27,16 @@ class CAboutDlg : public CDialog CAboutDlg(HWND hParent); ~CAboutDlg(); - void SetHiddenWnd(HWND hWnd) {m_hHiddenWnd = hWnd;} + void SetHiddenWnd(HWND hWnd) { m_hHiddenWnd = hWnd; } + protected: - LRESULT CALLBACK DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) override; - LRESULT DoCommand(int id); + LRESULT CALLBACK DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) override; + LRESULT DoCommand(int id); + bool PreTranslateMessage(MSG* pMsg) override; private: - HWND m_hParent; - HWND m_hHiddenWnd; - CHyperLink m_link; + HWND m_hParent; + HWND m_hHiddenWnd; + CHyperLink m_link; + std::wstring m_version; }; diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index b01e3ee0..d52b539b 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -537,7 +537,7 @@ STDMETHODIMP CMainWindow::Execute( void CMainWindow::About() const { CAboutDlg dlg(*this); - dlg.DoModal(g_hRes, IDD_ABOUTBOX, *this); + dlg.DoModal(g_hRes, IDD_ABOUTBOX, *this, NULL); } void CMainWindow::ShowCommandPalette()