From 28fde846312f5ade38d3ab42a669e1b005477439 Mon Sep 17 00:00:00 2001 From: Johannes Schultz Date: Sun, 10 Nov 2024 16:08:39 +0000 Subject: [PATCH] [Imp] On Vista and Wine 3.13 and newer, use Task Dialog for message boxes with "don't show again" checkbox. [Reg] On older systems, these messages are now always shown only once. git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@22143 56274372-70c3-4bfc-bfc3-4c3a0b034d27 --- mptrack/dlg_misc.cpp | 83 +++++++++++++++++--------------------------- mptrack/mptrack.rc | 18 ---------- mptrack/resource.h | 3 -- 3 files changed, 31 insertions(+), 73 deletions(-) diff --git a/mptrack/dlg_misc.cpp b/mptrack/dlg_misc.cpp index 47de1b4ae75..49b6d40c025 100644 --- a/mptrack/dlg_misc.cpp +++ b/mptrack/dlg_misc.cpp @@ -25,6 +25,10 @@ #include "../soundlib/mod_specifications.h" #include "../soundlib/plugins/PlugInterface.h" +#if MPT_WINNT_AT_LEAST(MPT_WIN_VISTA) +#include +#endif + OPENMPT_NAMESPACE_BEGIN @@ -1549,33 +1553,20 @@ void CInputDlg::OnOK() /////////////////////////////////////////////////////////////////////////////////////// // Messagebox with 'don't show again'-option. -class CMsgBoxHidable : public DialogBase -{ -public: - CMsgBoxHidable(const TCHAR *strMsg, bool checkStatus = true, CWnd* pParent = NULL); - enum { IDD = IDD_MSGBOX_HIDABLE }; - - const TCHAR *m_StrMsg; - int m_nCheckStatus; -protected: - void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support - BOOL OnInitDialog() override; -}; - - struct MsgBoxHidableMessage { + const TCHAR *mainTitle; const TCHAR *message; - uint32 mask; - bool defaultDontShowAgainStatus; // true for don't show again, false for show again. + const uint32 mask; + const bool defaultDontShowAgainStatus; // true for don't show again, false for show again. }; static constexpr MsgBoxHidableMessage HidableMessages[] = { - { _T("Note: First two bytes of oneshot samples are silenced for ProTracker compatibility."), 1, true }, - { _T("Hint: To create IT-files without MPT-specific extensions included, try compatibility export from File-menu."), 1 << 1, true }, - { _T("Hint: To create XM-files without MPT-specific extensions included, try compatibility export from File-menu."), 1 << 3, true }, - { _T("Warning: The exported file will not contain any of MPT's file format hacks."), 1 << 4, true }, + { _T("Compatibility Notice"), _T("The first two bytes of oneshot samples are silenced for ProTracker compatibility."), 1, true }, + { _T("Compatibility Hint"), _T("To create IT files without OpenMPT-specific extensions included, try compatibility export from File menu."), 1 << 1, true }, + { _T("Compatibility Hint"), _T("To create XM files without OpenMPT-specific extensions included, try compatibility export from File menu."), 1 << 3, true }, + { _T("Compatibility Notice"), _T("The exported file will not contain any of OpenMPT's file format hacks."), 1 << 4, true }, }; static_assert(mpt::array_size::size == enMsgBoxHidableMessage_count); @@ -1585,41 +1576,29 @@ static_assert(mpt::array_size::size == enMsgBoxHidabl // controls the show/don't show-flags. void MsgBoxHidable(enMsgBoxHidableMessage enMsg) { - // Check whether the message should be shown. - if((TrackerSettings::Instance().gnMsgBoxVisiblityFlags & HidableMessages[enMsg].mask) == 0) + const auto &msg = HidableMessages[enMsg]; + if((TrackerSettings::Instance().gnMsgBoxVisiblityFlags & msg.mask) == 0) return; - // Show dialog. - CMsgBoxHidable dlg(HidableMessages[enMsg].message, HidableMessages[enMsg].defaultDontShowAgainStatus); - dlg.DoModal(); - - // Update visibility flags. - const uint32 mask = HidableMessages[enMsg].mask; - if(dlg.m_nCheckStatus == BST_CHECKED) - TrackerSettings::Instance().gnMsgBoxVisiblityFlags &= ~mask; - else - TrackerSettings::Instance().gnMsgBoxVisiblityFlags |= mask; -} - - -CMsgBoxHidable::CMsgBoxHidable(const TCHAR *strMsg, bool checkStatus, CWnd* pParent) - : DialogBase(CMsgBoxHidable::IDD, pParent) - , m_StrMsg(strMsg) - , m_nCheckStatus((checkStatus) ? BST_CHECKED : BST_UNCHECKED) -{} - -BOOL CMsgBoxHidable::OnInitDialog() -{ - DialogBase::OnInitDialog(); - SetDlgItemText(IDC_MESSAGETEXT, m_StrMsg); - SetWindowText(AfxGetAppName()); - return TRUE; -} +#if MPT_WINNT_AT_LEAST(MPT_WIN_VISTA) + if(CTaskDialog::IsSupported() + && !(mpt::OS::Windows::IsWine() && theApp.GetWineVersion()->Version().IsBefore(mpt::OS::Wine::Version(3, 13, 0)))) + { + CTaskDialog taskDialog(msg.message, msg.mainTitle ? CString{msg.mainTitle} : CString{}, AfxGetAppName(), TDCBF_OK_BUTTON); + taskDialog.SetVerificationCheckboxText(_T("Do not show this message again")); + taskDialog.SetVerificationCheckbox(msg.defaultDontShowAgainStatus); + taskDialog.DoModal(); -void CMsgBoxHidable::DoDataExchange(CDataExchange* pDX) -{ - DialogBase::DoDataExchange(pDX); - DDX_Check(pDX, IDC_DONTSHOWAGAIN, m_nCheckStatus); + if(taskDialog.GetVerificationCheckboxState()) + TrackerSettings::Instance().gnMsgBoxVisiblityFlags &= ~msg.mask; + else + TrackerSettings::Instance().gnMsgBoxVisiblityFlags |= msg.mask; + } else +#endif + { + Reporting::Information(msg.message, msg.mainTitle ? CString{msg.mainTitle} : CString{}); + TrackerSettings::Instance().gnMsgBoxVisiblityFlags |= msg.mask; + } } diff --git a/mptrack/mptrack.rc b/mptrack/mptrack.rc index 58b7f85fa9f..8071ca44755 100644 --- a/mptrack/mptrack.rc +++ b/mptrack/mptrack.rc @@ -3339,16 +3339,6 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK // Dialog // -IDD_MSGBOX_HIDABLE DIALOGEX 0, 0, 187, 71 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "OK",IDOK,150,50,30,14 - PUSHBUTTON "Cancel",IDCANCEL,111,49,30,14,NOT WS_VISIBLE - CONTROL "Don't show this again.",IDC_DONTSHOWAGAIN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,54,90,10 - LTEXT "Static",IDC_MESSAGETEXT,7,7,173,40 -END - IDD_MIDIPARAMCONTROL DIALOGEX 0, 0, 413, 247 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "MIDI Mapping" @@ -3492,14 +3482,6 @@ END #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO BEGIN - IDD_MSGBOX_HIDABLE, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 180 - TOPMARGIN, 7 - BOTTOMMARGIN, 64 - END - IDD_MIDIPARAMCONTROL, DIALOG BEGIN RIGHTMARGIN, 409 diff --git a/mptrack/resource.h b/mptrack/resource.h index ca4fda63b29..32de7b1d7bb 100644 --- a/mptrack/resource.h +++ b/mptrack/resource.h @@ -95,7 +95,6 @@ #define IDD_MIXSAMPLES 513 #define IDS_ERR_TUNING_SERIALISATION 514 #define IDD_MIDIPARAMCONTROL 515 -#define IDD_MSGBOX_HIDABLE 516 #define IDD_ADDSILENCE 517 #define IDD_OPLEXPORT 518 #define IDD_OPL_PARAMS 520 @@ -802,8 +801,6 @@ #define IDC_EDIT_STRETCHPARAMS 2338 #define IDC_MIDI_MACRO_CONTROL 2339 #define IDC_MIDIPLAYPATTERNONMIDIIN 2340 -#define IDC_DONTSHOWAGAIN 2341 -#define IDC_MESSAGETEXT 2342 #define IDC_SAMPLE_DCOFFSET 2343 #define IDC_OPTIONS_DIR_MODS 2344 #define IDC_OPTIONS_DIR_SAMPS 2345