diff --git a/NanaZip.Shared/ModernWin32MessageBox.cpp b/NanaZip.Shared/ModernWin32MessageBox.cpp new file mode 100644 index 0000000..16b7a7f --- /dev/null +++ b/NanaZip.Shared/ModernWin32MessageBox.cpp @@ -0,0 +1,103 @@ +/* + * PROJECT: NanaZip + * FILE: ModernWin32MessageBox.cpp + * PURPOSE: Implementation for Modern Win32 Message Box + * + * LICENSE: The MIT License + * + * DEVELOPER: Mouri_Naruto (Mouri_Naruto AT Outlook.com) + */ + +#include + +#include +#pragma comment(lib,"comctl32.lib") + +EXTERN_C int WINAPI ModernMessageBoxW( + _In_opt_ HWND hWnd, + _In_opt_ LPCWSTR lpText, + _In_opt_ LPCWSTR lpCaption, + _In_ UINT uType) +{ + if (uType != (uType & (MB_ICONMASK | MB_TYPEMASK))) + { + return ::MessageBoxW(hWnd, lpText, lpCaption, uType); + } + + TASKDIALOGCONFIG TaskDialogConfig = { 0 }; + + TaskDialogConfig.cbSize = sizeof(TASKDIALOGCONFIG); + TaskDialogConfig.hwndParent = hWnd; + TaskDialogConfig.dwFlags = TDF_ALLOW_DIALOG_CANCELLATION; + TaskDialogConfig.pszWindowTitle = lpCaption; + TaskDialogConfig.pszMainInstruction = lpText; + + switch (uType & MB_TYPEMASK) + { + case MB_OK: + TaskDialogConfig.dwCommonButtons = + TDCBF_OK_BUTTON; + break; + case MB_OKCANCEL: + TaskDialogConfig.dwCommonButtons = + TDCBF_OK_BUTTON | TDCBF_CANCEL_BUTTON; + break; + case MB_YESNOCANCEL: + TaskDialogConfig.dwCommonButtons = + TDCBF_YES_BUTTON | TDCBF_NO_BUTTON | TDCBF_CANCEL_BUTTON; + break; + case MB_YESNO: + TaskDialogConfig.dwCommonButtons = + TDCBF_YES_BUTTON | TDCBF_NO_BUTTON; + break; + case MB_RETRYCANCEL: + TaskDialogConfig.dwCommonButtons = + TDCBF_RETRY_BUTTON | TDCBF_CANCEL_BUTTON; + break; + default: + return ::MessageBoxW(hWnd, lpText, lpCaption, uType); + } + + switch (uType & MB_ICONMASK) + { + case MB_ICONHAND: + TaskDialogConfig.pszMainIcon = TD_ERROR_ICON; + break; + case MB_ICONQUESTION: + TaskDialogConfig.dwFlags |= TDF_USE_HICON_MAIN; + TaskDialogConfig.hMainIcon = ::LoadIconW(nullptr, IDI_QUESTION); + break; + case MB_ICONEXCLAMATION: + TaskDialogConfig.pszMainIcon = TD_WARNING_ICON; + break; + case MB_ICONASTERISK: + TaskDialogConfig.pszMainIcon = TD_INFORMATION_ICON; + break; + default: + break; + } + + int ButtonID = 0; + + HRESULT hr = ::TaskDialogIndirect( + &TaskDialogConfig, + &ButtonID, + nullptr, + nullptr); + + if (ButtonID == 0) + { + ::SetLastError(hr); + } + + return ButtonID; +} + +#if defined(_M_IX86) +#pragma warning(suppress:4483) +extern "C" __declspec(selectany) void const* const __identifier("_imp__MessageBoxW@16") = reinterpret_cast(::ModernMessageBoxW); +#pragma comment(linker, "/include:__imp__MessageBoxW@16") +#else +extern "C" __declspec(selectany) void const* const __imp_MessageBoxW = reinterpret_cast(::ModernMessageBoxW); +#pragma comment(linker, "/include:__imp_MessageBoxW") +#endif diff --git a/NanaZip.Shared/NanaZip.Shared.ModernExperienceShims.filters b/NanaZip.Shared/NanaZip.Shared.ModernExperienceShims.filters new file mode 100644 index 0000000..8680540 --- /dev/null +++ b/NanaZip.Shared/NanaZip.Shared.ModernExperienceShims.filters @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/NanaZip.Shared/NanaZip.Shared.ModernExperienceShims.props b/NanaZip.Shared/NanaZip.Shared.ModernExperienceShims.props new file mode 100644 index 0000000..b1cf473 --- /dev/null +++ b/NanaZip.Shared/NanaZip.Shared.ModernExperienceShims.props @@ -0,0 +1,14 @@ + + + + $(MSBuildThisFileDirectory);$(IncludePath) + + + + %(PreprocessorDefinitions) + + + $(MileProjectObjectsPath)$(Configuration)\NanaZip.Shared.ModernExperienceShims\$(Platform)\ModernWin32MessageBox.obj;%(AdditionalDependencies) + + + \ No newline at end of file diff --git a/NanaZip.Shared/NanaZip.Shared.ModernExperienceShims.vcxproj b/NanaZip.Shared/NanaZip.Shared.ModernExperienceShims.vcxproj new file mode 100644 index 0000000..cf8ed31 --- /dev/null +++ b/NanaZip.Shared/NanaZip.Shared.ModernExperienceShims.vcxproj @@ -0,0 +1,21 @@ + + + + + + + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C} + NanaZip.Shared.ModernExperienceShims + StaticLibrary + + + + + + + + + + + + \ No newline at end of file diff --git a/NanaZip.sln b/NanaZip.sln index 33311f5..4c63423 100644 --- a/NanaZip.sln +++ b/NanaZip.sln @@ -6,6 +6,7 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NanaZipShellExtension", "NanaZipShellExtension\NanaZipShellExtension.vcxproj", "{F17D4837-7943-4361-9527-2AF9CACE477D}" ProjectSection(ProjectDependencies) = postProject {84E27A16-CBC7-466C-971F-2A4E0F2F95BE} = {84E27A16-CBC7-466C-971F-2A4E0F2F95BE} + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C} = {501956AB-67C3-47FA-BE2B-8AEFF463AF1C} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Mile.Library", "Mile.Cpp\Mile.Library\Mile.Library.vcxproj", "{84E27A16-CBC7-466C-971F-2A4E0F2F95BE}" @@ -14,6 +15,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NanaZipSfxWindows", "NanaZi ProjectSection(ProjectDependencies) = postProject {84E27A16-CBC7-466C-971F-2A4E0F2F95BE} = {84E27A16-CBC7-466C-971F-2A4E0F2F95BE} {6F0E7455-ECE1-440D-9EA2-8C18E4F1CBE6} = {6F0E7455-ECE1-440D-9EA2-8C18E4F1CBE6} + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C} = {501956AB-67C3-47FA-BE2B-8AEFF463AF1C} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NanaZipSfxConsole", "NanaZipSfxConsole\NanaZipSfxConsole.vcxproj", "{96C0A1A0-D964-4725-AFDC-73EBF7FC1416}" @@ -26,6 +28,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NanaZipSfxSetup", "NanaZipS ProjectSection(ProjectDependencies) = postProject {84E27A16-CBC7-466C-971F-2A4E0F2F95BE} = {84E27A16-CBC7-466C-971F-2A4E0F2F95BE} {6F0E7455-ECE1-440D-9EA2-8C18E4F1CBE6} = {6F0E7455-ECE1-440D-9EA2-8C18E4F1CBE6} + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C} = {501956AB-67C3-47FA-BE2B-8AEFF463AF1C} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NanaZipCore", "NanaZipCore\NanaZipCore.vcxproj", "{86D65350-E2AE-47BC-AE05-FC35D3BAAE6C}" @@ -40,6 +43,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NanaZip", "NanaZip\NanaZip. {D33E771E-6B30-4EFB-9DEC-A9148D50080D} = {D33E771E-6B30-4EFB-9DEC-A9148D50080D} {F17D4837-7943-4361-9527-2AF9CACE477D} = {F17D4837-7943-4361-9527-2AF9CACE477D} {86D65350-E2AE-47BC-AE05-FC35D3BAAE6C} = {86D65350-E2AE-47BC-AE05-FC35D3BAAE6C} + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C} = {501956AB-67C3-47FA-BE2B-8AEFF463AF1C} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NanaZipWindows", "NanaZipWindows\NanaZipWindows.vcxproj", "{D33E771E-6B30-4EFB-9DEC-A9148D50080D}" @@ -47,6 +51,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NanaZipWindows", "NanaZipWi {84E27A16-CBC7-466C-971F-2A4E0F2F95BE} = {84E27A16-CBC7-466C-971F-2A4E0F2F95BE} {86D65350-E2AE-47BC-AE05-FC35D3BAAE6C} = {86D65350-E2AE-47BC-AE05-FC35D3BAAE6C} {C11F288B-9E3C-4DA9-8206-852BB91C7E4C} = {C11F288B-9E3C-4DA9-8206-852BB91C7E4C} + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C} = {501956AB-67C3-47FA-BE2B-8AEFF463AF1C} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NanaZipConsole", "NanaZipConsole\NanaZipConsole.vcxproj", "{D866CA04-DF51-4660-BA4D-F82426A3A522}" @@ -70,6 +75,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NanaZip.Shared.SevenZipZSta {84E27A16-CBC7-466C-971F-2A4E0F2F95BE} = {84E27A16-CBC7-466C-971F-2A4E0F2F95BE} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NanaZip.Shared.ModernExperienceShims", "NanaZip.Shared\NanaZip.Shared.ModernExperienceShims.vcxproj", "{501956AB-67C3-47FA-BE2B-8AEFF463AF1C}" + ProjectSection(ProjectDependencies) = postProject + {84E27A16-CBC7-466C-971F-2A4E0F2F95BE} = {84E27A16-CBC7-466C-971F-2A4E0F2F95BE} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM64 = Debug|ARM64 @@ -218,12 +228,25 @@ Global {6F0E7455-ECE1-440D-9EA2-8C18E4F1CBE6}.Release|x64.Build.0 = Release|x64 {6F0E7455-ECE1-440D-9EA2-8C18E4F1CBE6}.Release|x86.ActiveCfg = Release|Win32 {6F0E7455-ECE1-440D-9EA2-8C18E4F1CBE6}.Release|x86.Build.0 = Release|Win32 + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C}.Debug|ARM64.Build.0 = Debug|ARM64 + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C}.Debug|x64.ActiveCfg = Debug|x64 + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C}.Debug|x64.Build.0 = Debug|x64 + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C}.Debug|x86.ActiveCfg = Debug|Win32 + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C}.Debug|x86.Build.0 = Debug|Win32 + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C}.Release|ARM64.ActiveCfg = Release|ARM64 + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C}.Release|ARM64.Build.0 = Release|ARM64 + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C}.Release|x64.ActiveCfg = Release|x64 + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C}.Release|x64.Build.0 = Release|x64 + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C}.Release|x86.ActiveCfg = Release|Win32 + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {6F0E7455-ECE1-440D-9EA2-8C18E4F1CBE6} = {685BAF3E-2C48-4904-B37E-EBEA67680327} + {501956AB-67C3-47FA-BE2B-8AEFF463AF1C} = {685BAF3E-2C48-4904-B37E-EBEA67680327} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DE2C16C4-5306-4103-9C2A-749DC32B5CA6} diff --git a/NanaZip/NanaZip.vcxproj b/NanaZip/NanaZip.vcxproj index c989439..5a3a3c7 100644 --- a/NanaZip/NanaZip.vcxproj +++ b/NanaZip/NanaZip.vcxproj @@ -14,6 +14,7 @@ + %(AdditionalOptions) /Wv:18 diff --git a/NanaZipSfxSetup/NanaZipSfxSetup.vcxproj b/NanaZipSfxSetup/NanaZipSfxSetup.vcxproj index 32525dc..f4a7ad6 100644 --- a/NanaZipSfxSetup/NanaZipSfxSetup.vcxproj +++ b/NanaZipSfxSetup/NanaZipSfxSetup.vcxproj @@ -10,6 +10,7 @@ + NanaZipSetup .sfx diff --git a/NanaZipSfxWindows/NanaZipSfxWindows.vcxproj b/NanaZipSfxWindows/NanaZipSfxWindows.vcxproj index 152db7b..269f946 100644 --- a/NanaZipSfxWindows/NanaZipSfxWindows.vcxproj +++ b/NanaZipSfxWindows/NanaZipSfxWindows.vcxproj @@ -10,6 +10,7 @@ + NanaZipWindows .sfx diff --git a/NanaZipShellExtension/NanaZipShellExtension.vcxproj b/NanaZipShellExtension/NanaZipShellExtension.vcxproj index 6f01cdb..f3b24fd 100644 --- a/NanaZipShellExtension/NanaZipShellExtension.vcxproj +++ b/NanaZipShellExtension/NanaZipShellExtension.vcxproj @@ -15,6 +15,7 @@ + %(AdditionalOptions) /Wv:18 diff --git a/NanaZipWindows/NanaZipWindows.vcxproj b/NanaZipWindows/NanaZipWindows.vcxproj index 2dc2860..7f99971 100644 --- a/NanaZipWindows/NanaZipWindows.vcxproj +++ b/NanaZipWindows/NanaZipWindows.vcxproj @@ -15,6 +15,7 @@ + %(AdditionalOptions) /Wv:18