From: <sv...@op...> - 2024-11-10 16:08:48
|
Author: sagamusix Date: Sun Nov 10 17:08:39 2024 New Revision: 22143 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22143 Log: [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. Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/resource.h Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp ============================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp Sun Nov 10 16:40:44 2024 (r22142) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp Sun Nov 10 17:08:39 2024 (r22143) @@ -25,6 +25,10 @@ #include "../soundlib/mod_specifications.h" #include "../soundlib/plugins/PlugInterface.h" +#if MPT_WINNT_AT_LEAST(MPT_WIN_VISTA) +#include <afxtaskdialog.h> +#endif + OPENMPT_NAMESPACE_BEGIN @@ -1549,33 +1553,20 @@ /////////////////////////////////////////////////////////////////////////////////////// // 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<decltype(HidableMessages)>::size == enMsgBoxHidableMessage_count); @@ -1585,41 +1576,29 @@ // 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; + } } Modified: trunk/OpenMPT/mptrack/mptrack.rc ============================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc Sun Nov 10 16:40:44 2024 (r22142) +++ trunk/OpenMPT/mptrack/mptrack.rc Sun Nov 10 17:08:39 2024 (r22143) @@ -3339,16 +3339,6 @@ // 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 @@ #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 Modified: trunk/OpenMPT/mptrack/resource.h ============================================================================== --- trunk/OpenMPT/mptrack/resource.h Sun Nov 10 16:40:44 2024 (r22142) +++ trunk/OpenMPT/mptrack/resource.h Sun Nov 10 17:08:39 2024 (r22143) @@ -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 |