Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/lepoco/wpfui into fe…
Browse files Browse the repository at this point in the history
…ature/net8-support
  • Loading branch information
pomianowski committed Nov 22, 2023
2 parents 19fc9b7 + 01e464f commit c82e9e2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Wpf.Ui/Interop/UnsafeNativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,10 @@ public static bool RemoveWindowTitlebarContents(IntPtr handle)
var windowStyleLong = User32.GetWindowLong(handle, User32.GWL.GWL_STYLE);
windowStyleLong &= ~(int)User32.WS.SYSMENU;

var result = User32.SetWindowLong(handle, User32.GWL.GWL_STYLE, windowStyleLong);
IntPtr result = SetWindowLong(handle, User32.GWL.GWL_STYLE, windowStyleLong);
long resultValue = result.ToInt64();

return result > 0x0;
return resultValue > 0x0;
}

/// <summary>
Expand Down Expand Up @@ -575,4 +576,14 @@ private static bool GetHandle(Window? window, out IntPtr windowHandle)

return windowHandle != IntPtr.Zero;
}

private static IntPtr SetWindowLong(IntPtr handle, User32.GWL nIndex, long windowStyleLong)
{
if (IntPtr.Size == 4)
{
return new IntPtr(User32.SetWindowLong(handle, (int)nIndex, (int)windowStyleLong));
}

return User32.SetWindowLongPtr(handle, (int)nIndex, (IntPtr)windowStyleLong);
}
}
6 changes: 6 additions & 0 deletions src/Wpf.Ui/Interop/User32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,12 @@ [In] IntPtr lParam
[DllImport(Libraries.User32, CharSet = CharSet.Auto)]
public static extern IntPtr SetWindowLongPtr([In] IntPtr hWnd, [In] int nIndex, [In] IntPtr dwNewLong);

/// <summary>
/// Changes an attribute of the specified window.
/// </summary>
[DllImport(Libraries.User32, CharSet = CharSet.Auto, SetLastError = true)]
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

/// <summary>
/// Destroys an icon and frees any memory the icon occupied.
/// </summary>
Expand Down

0 comments on commit c82e9e2

Please sign in to comment.