diff --git a/README.md b/README.md index dd71352..fcb3883 100644 --- a/README.md +++ b/README.md @@ -84,11 +84,11 @@ The `Ookii.Dialogs.Wpf.VistaOpenFileDialog`, `Ookii.Dialogs.Wpf.VistaSaveFileDia The classes have been designed to resemble the original WPF classes to make it easy to switch. When the classes are used on Windows XP, they will automatically fall back to the old style dialog; this is also true for the `VistaFolderBrowserDialog`; that class provides a complete implementation of a folder browser dialog for WPF, old as well as new style. -## .NET Core 3.1 & .NET 5 pre-requisites **before** Ookii.Dialogs.Wpf v3.1.0 +## .NET 5 pre-requisites **before** Ookii.Dialogs.Wpf v3.1.0 -> **NOTE: Starting with Ookii.Dialogs.Wpf v3.1.0 an app.manifest is no longer required when using in .NET 5 or .NET Core 3.1 apps** +> **NOTE: Starting with Ookii.Dialogs.Wpf v3.1.0 an app.manifest is no longer required when using in .NET 5 apps** -Ookii Dialogs leverages the components and visual styles of the Windows Common Controls library (`comctl32.dll`), and WPF applications targeting .NET Core 3.1 and/or .NET 5 must add an [application manifest](https://docs.microsoft.com/en-us/windows/win32/sbscs/application-manifests) (`app.manifest`) to their projects with a reference to `Microsoft.Windows.Common-Controls`. +Ookii Dialogs leverages the components and visual styles of the Windows Common Controls library (`comctl32.dll`), and WPF applications targeting .NET 5 must add an [application manifest](https://docs.microsoft.com/en-us/windows/win32/sbscs/application-manifests) (`app.manifest`) to their projects with a reference to `Microsoft.Windows.Common-Controls`. Without the application manifest, you'll get an error with a message similar to the below: diff --git a/sample/Ookii.Dialogs.Wpf.Sample/Ookii.Dialogs.Wpf.Sample.csproj b/sample/Ookii.Dialogs.Wpf.Sample/Ookii.Dialogs.Wpf.Sample.csproj index 867cb83..7c01fb2 100644 --- a/sample/Ookii.Dialogs.Wpf.Sample/Ookii.Dialogs.Wpf.Sample.csproj +++ b/sample/Ookii.Dialogs.Wpf.Sample/Ookii.Dialogs.Wpf.Sample.csproj @@ -1,7 +1,7 @@  - net6.0-windows;net5.0-windows;netcoreapp3.1;net462 + net6.0-windows;net5.0-windows;net462 WinExe true true diff --git a/src/Ookii.Dialogs.Wpf/AnimationResource.cs b/src/Ookii.Dialogs.Wpf/AnimationResource.cs index 7a3bb07..6373478 100644 --- a/src/Ookii.Dialogs.Wpf/AnimationResource.cs +++ b/src/Ookii.Dialogs.Wpf/AnimationResource.cs @@ -76,7 +76,7 @@ public static AnimationResource GetShellAnimation(ShellAnimation animation) internal FreeLibrarySafeHandle LoadLibrary() { - var handle = NativeMethods.LoadLibraryEx(ResourceFile, default, Windows.Win32.System.LibraryLoader.LOAD_LIBRARY_FLAGS.LOAD_LIBRARY_AS_DATAFILE); + var handle = NativeMethods.LoadLibraryEx(ResourceFile, Windows.Win32.System.LibraryLoader.LOAD_LIBRARY_FLAGS.LOAD_LIBRARY_AS_DATAFILE); if( handle.IsInvalid ) { int error = System.Runtime.InteropServices.Marshal.GetLastWin32Error(); diff --git a/src/Ookii.Dialogs.Wpf/ComCtlv6ActivationContext.cs b/src/Ookii.Dialogs.Wpf/ComCtlv6ActivationContext.cs index cc3e8ca..582449b 100644 --- a/src/Ookii.Dialogs.Wpf/ComCtlv6ActivationContext.cs +++ b/src/Ookii.Dialogs.Wpf/ComCtlv6ActivationContext.cs @@ -25,7 +25,7 @@ sealed class ComCtlv6ActivationContext : IDisposable // Private data private nuint _cookie; private static ACTCTXW _enableThemingActivationContext; - private static SafeFileHandle _activationContext; + private static ReleaseActCtxSafeHandle _activationContext; private static bool _contextCreationSucceeded; private static readonly object _contextCreationLock = new object(); diff --git a/src/Ookii.Dialogs.Wpf/CredentialDialog.cs b/src/Ookii.Dialogs.Wpf/CredentialDialog.cs index 5fcefcb..b79a5af 100644 --- a/src/Ookii.Dialogs.Wpf/CredentialDialog.cs +++ b/src/Ookii.Dialogs.Wpf/CredentialDialog.cs @@ -674,7 +674,7 @@ public unsafe static NetworkCredential RetrieveCredential(string target, byte[] if (cred != null) return cred; - var result = NativeMethods.CredRead(target, (uint)CRED_TYPE.CRED_TYPE_GENERIC, 0, out var credential); + var result = NativeMethods.CredRead(target, (uint)CRED_TYPE.CRED_TYPE_GENERIC, out var credential); int error = System.Runtime.InteropServices.Marshal.GetLastWin32Error(); if (result) { @@ -759,7 +759,7 @@ public static bool DeleteCredential(string target) found = _applicationInstanceCredentialCache.Remove(target); } - if (NativeMethods.CredDelete(target, (uint)CRED_TYPE.CRED_TYPE_GENERIC, 0)) + if (NativeMethods.CredDelete(target, (uint)CRED_TYPE.CRED_TYPE_GENERIC)) { found = true; } @@ -805,7 +805,7 @@ private unsafe bool PromptForCredentialsCredUI(HWND owner, bool storedCredential Password.AsSpan().CopyTo(pwSpan); WIN32_ERROR result; fixed (BOOL* b = &_isSaveChecked) - result = (WIN32_ERROR)NativeMethods.CredUIPromptForCredentials(info, Target, ref Unsafe.AsRef((void*)0), 0, ref userSpan, NativeMethods.CREDUI_MAX_USERNAME_LENGTH, ref pwSpan, NativeMethods.CREDUI_MAX_PASSWORD_LENGTH, b, flags); + result = (WIN32_ERROR)NativeMethods.CredUIPromptForCredentials(info, Target, 0, ref userSpan, NativeMethods.CREDUI_MAX_USERNAME_LENGTH, ref pwSpan, NativeMethods.CREDUI_MAX_PASSWORD_LENGTH, b, flags); switch (result) { diff --git a/src/Ookii.Dialogs.Wpf/Interop/Win32Resources.cs b/src/Ookii.Dialogs.Wpf/Interop/Win32Resources.cs index d954c63..0d9d8ec 100644 --- a/src/Ookii.Dialogs.Wpf/Interop/Win32Resources.cs +++ b/src/Ookii.Dialogs.Wpf/Interop/Win32Resources.cs @@ -32,7 +32,7 @@ class Win32Resources : IDisposable public Win32Resources(string module) { - _moduleHandle = NativeMethods.LoadLibraryEx(module, default, LOAD_LIBRARY_FLAGS.LOAD_LIBRARY_AS_DATAFILE); + _moduleHandle = NativeMethods.LoadLibraryEx(module, LOAD_LIBRARY_FLAGS.LOAD_LIBRARY_AS_DATAFILE); if (_moduleHandle.IsInvalid) throw new System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error()); } diff --git a/src/Ookii.Dialogs.Wpf/Ookii.Dialogs.Wpf.csproj b/src/Ookii.Dialogs.Wpf/Ookii.Dialogs.Wpf.csproj index 34c0703..cf3068e 100644 --- a/src/Ookii.Dialogs.Wpf/Ookii.Dialogs.Wpf.csproj +++ b/src/Ookii.Dialogs.Wpf/Ookii.Dialogs.Wpf.csproj @@ -1,7 +1,7 @@  - net6.0-windows;net5.0-windows;netcoreapp3.1;net462 + net6.0-windows;net5.0-windows;net462 true true Ookii.Dialogs.Wpf @@ -54,10 +54,6 @@ $(DefineConstants);NETFX - - $(DefineConstants);NETCORE31 - - $(DefineConstants);NET5 @@ -68,7 +64,7 @@ - + diff --git a/src/Ookii.Dialogs.Wpf/ProgressDialog.cs b/src/Ookii.Dialogs.Wpf/ProgressDialog.cs index 8fdb8ac..e8c6668 100644 --- a/src/Ookii.Dialogs.Wpf/ProgressDialog.cs +++ b/src/Ookii.Dialogs.Wpf/ProgressDialog.cs @@ -149,7 +149,7 @@ public string Text unsafe { if (_dialog != null) - _dialog.SetLine(1, Text, UseCompactPathsForText, default); + _dialog.SetLine(1, Text, UseCompactPathsForText); } } } @@ -181,7 +181,7 @@ public bool UseCompactPathsForText unsafe { if ( _dialog != null ) - _dialog.SetLine(1, Text, UseCompactPathsForText, default); + _dialog.SetLine(1, Text, UseCompactPathsForText); } } } @@ -212,7 +212,7 @@ public string Description unsafe { if (_dialog != null) - _dialog.SetLine(2, Description, UseCompactPathsForDescription, default); + _dialog.SetLine(2, Description, UseCompactPathsForDescription); } } } @@ -244,7 +244,7 @@ public bool UseCompactPathsForDescription unsafe { if (_dialog != null) - _dialog.SetLine(2, Description, UseCompactPathsForDescription, default); + _dialog.SetLine(2, Description, UseCompactPathsForDescription); } } } @@ -772,9 +772,9 @@ private unsafe void RunProgressDialog(IntPtr owner, object argument, Cancellatio _dialog.SetAnimation(_currentAnimationModuleHandle, (ushort)Animation.ResourceId); if( CancellationText.Length > 0 ) - _dialog.SetCancelMsg(CancellationText, null); - _dialog.SetLine(1, Text, UseCompactPathsForText, default); - _dialog.SetLine(2, Description, UseCompactPathsForDescription, default); + _dialog.SetCancelMsg(CancellationText); + _dialog.SetLine(1, Text, UseCompactPathsForText); + _dialog.SetLine(2, Description, UseCompactPathsForDescription); uint flags = NativeMethods.PROGDLG_NORMAL; if( owner != IntPtr.Zero ) diff --git a/src/Ookii.Dialogs.Wpf/VistaFolderBrowserDialog.cs b/src/Ookii.Dialogs.Wpf/VistaFolderBrowserDialog.cs index 886d29f..7761990 100644 --- a/src/Ookii.Dialogs.Wpf/VistaFolderBrowserDialog.cs +++ b/src/Ookii.Dialogs.Wpf/VistaFolderBrowserDialog.cs @@ -303,9 +303,10 @@ private bool RunDialog(HWND owner) private unsafe bool RunDialogDownlevel(HWND owner) { IntPtr resultItemIdList = IntPtr.Zero; - if (NativeMethods.SHGetSpecialFolderLocation(owner, (int)RootFolder, out ITEMIDLIST* rootItemIdList) != HRESULT.S_OK) + ITEMIDLIST* rootItemIdList; + if (NativeMethods.SHGetSpecialFolderLocation(owner, (int)RootFolder, &rootItemIdList) != HRESULT.S_OK) { - if (NativeMethods.SHGetSpecialFolderLocation(owner, 0, out rootItemIdList) != 0) + if (NativeMethods.SHGetSpecialFolderLocation(owner, 0, &rootItemIdList) != 0) { throw new InvalidOperationException(Properties.Resources.FolderBrowserDialogNoRootFolder); } diff --git a/src/Ookii.Dialogs.Wpf/VistaOpenFileDialog.cs b/src/Ookii.Dialogs.Wpf/VistaOpenFileDialog.cs index 9a44fa6..6d6ea15 100644 --- a/src/Ookii.Dialogs.Wpf/VistaOpenFileDialog.cs +++ b/src/Ookii.Dialogs.Wpf/VistaOpenFileDialog.cs @@ -238,8 +238,7 @@ internal unsafe override void GetResult(IFileDialog dialog) if( ShowReadOnly ) { IFileDialogCustomize customize = (IFileDialogCustomize)dialog; - uint selected; - customize.GetSelectedControlItem(_openDropDownId, &selected); + customize.GetSelectedControlItem(_openDropDownId, out var selected); _readOnlyChecked = (selected == _readOnlyItemId); } diff --git a/src/Ookii.Dialogs/Ookii.Dialogs.csproj b/src/Ookii.Dialogs/Ookii.Dialogs.csproj index d5cea79..27db64e 100644 --- a/src/Ookii.Dialogs/Ookii.Dialogs.csproj +++ b/src/Ookii.Dialogs/Ookii.Dialogs.csproj @@ -1,7 +1,7 @@  - net6.0-windows;net5.0-windows;netcoreapp3.1;net462 + net6.0-windows;net5.0-windows;net462 true true