Skip to content
This repository was archived by the owner on Jul 26, 2023. It is now read-only.

Commit 9f637a0

Browse files
- Changing DllImport EntryPoint name for SetWindowLongPtr64 from nameof(SetWindowLongPtr) to "SetWindowLongPtr"
- Adding definition for AdjustWindowRectEx
1 parent b456fd6 commit 9f637a0

File tree

2 files changed

+55
-5
lines changed

2 files changed

+55
-5
lines changed

src/User32/PublicAPI.Unshipped.txt

+6-4
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ PInvoke.User32.SendMessageTimeoutFlags.SMTO_BLOCK = 1 -> PInvoke.User32.SendMess
3333
PInvoke.User32.SendMessageTimeoutFlags.SMTO_ERRORONEXIT = 32 -> PInvoke.User32.SendMessageTimeoutFlags
3434
PInvoke.User32.SendMessageTimeoutFlags.SMTO_NORMAL = 0 -> PInvoke.User32.SendMessageTimeoutFlags
3535
PInvoke.User32.SendMessageTimeoutFlags.SMTO_NOTIMEOUTIFNOTHUNG = 8 -> PInvoke.User32.SendMessageTimeoutFlags
36-
PInvoke.User32.WindowMessage.WM_DPICHANGED_AFTERPARENT = 739 -> PInvoke.User32.WindowMessage
37-
PInvoke.User32.WindowMessage.WM_DPICHANGED_BEFOREPARENT = 738 -> PInvoke.User32.WindowMessage
38-
PInvoke.User32.WindowMessage.WM_GETDPISCALEDSIZE = 740 -> PInvoke.User32.WindowMessage
3936
PInvoke.User32.WindowLongIndexFlags.GWLP_ID = PInvoke.User32.WindowLongIndexFlags.GWL_STYLE | PInvoke.User32.WindowLongIndexFlags.DWLP_DLGPROC -> PInvoke.User32.WindowLongIndexFlags
4037
PInvoke.User32.WindowLongIndexFlags.GWLP_USERDATA = -21 -> PInvoke.User32.WindowLongIndexFlags
4138
PInvoke.User32.WindowLongIndexFlags.GWLP_WNDPROC = PInvoke.User32.WindowLongIndexFlags.GWL_STYLE | PInvoke.User32.WindowLongIndexFlags.DWLP_DLGPROC | PInvoke.User32.WindowLongIndexFlags.DWLP_USER -> PInvoke.User32.WindowLongIndexFlags
39+
PInvoke.User32.WindowMessage.WM_DPICHANGED_AFTERPARENT = 739 -> PInvoke.User32.WindowMessage
40+
PInvoke.User32.WindowMessage.WM_DPICHANGED_BEFOREPARENT = 738 -> PInvoke.User32.WindowMessage
41+
PInvoke.User32.WindowMessage.WM_GETDPISCALEDSIZE = 740 -> PInvoke.User32.WindowMessage
4242
PInvoke.User32.mouse_eventFlags
4343
PInvoke.User32.mouse_eventFlags.MOUSEEVENTF_ABSOLUTE = 32768 -> PInvoke.User32.mouse_eventFlags
4444
PInvoke.User32.mouse_eventFlags.MOUSEEVENTF_HWHEEL = 4096 -> PInvoke.User32.mouse_eventFlags
@@ -52,14 +52,16 @@ PInvoke.User32.mouse_eventFlags.MOUSEEVENTF_RIGHTUP = 16 -> PInvoke.User32.mouse
5252
PInvoke.User32.mouse_eventFlags.MOUSEEVENTF_WHEEL = 2048 -> PInvoke.User32.mouse_eventFlags
5353
PInvoke.User32.mouse_eventFlags.MOUSEEVENTF_XDOWN = 128 -> PInvoke.User32.mouse_eventFlags
5454
PInvoke.User32.mouse_eventFlags.MOUSEEVENTF_XUP = 256 -> PInvoke.User32.mouse_eventFlags
55+
static PInvoke.User32.AdjustWindowRectEx(System.IntPtr lpRect, PInvoke.User32.WindowStyles dwStyle, bool bMenu, PInvoke.User32.WindowStylesEx dwExStyle) -> bool
5556
static PInvoke.User32.AdjustWindowRectExForDpi(System.IntPtr lpRect, PInvoke.User32.WindowStyles dwStyle, bool bMenu, PInvoke.User32.WindowStylesEx dwExStyle, int dpi) -> bool
5657
static PInvoke.User32.CreateWindowEx(PInvoke.User32.WindowStylesEx dwExStyle, short lpClassName, string lpWindowName, PInvoke.User32.WindowStyles dwStyle, int x, int y, int nWidth, int nHeight, System.IntPtr hWndParent, System.IntPtr hMenu, System.IntPtr hInstance, System.IntPtr lpParam) -> System.IntPtr
5758
static PInvoke.User32.CreateWindowEx(PInvoke.User32.WindowStylesEx dwExStyle, short lpClassName, string lpWindowName, PInvoke.User32.WindowStyles dwStyle, int x, int y, int nWidth, int nHeight, System.IntPtr hWndParent, System.IntPtr hMenu, System.IntPtr hInstance, void* lpParam) -> System.IntPtr
5859
static PInvoke.User32.GetNextWindow(System.IntPtr hWnd, PInvoke.User32.GetNextWindowCommands wCmd) -> System.IntPtr
59-
static PInvoke.User32.SetWindowLongPtr(System.IntPtr hWnd, PInvoke.User32.WindowLongIndexFlags nIndex, void* dwNewLong) -> void*
6060
static PInvoke.User32.SetWindowLongPtr(System.IntPtr hWnd, PInvoke.User32.WindowLongIndexFlags nIndex, System.IntPtr dwNewLong) -> System.IntPtr
61+
static PInvoke.User32.SetWindowLongPtr(System.IntPtr hWnd, PInvoke.User32.WindowLongIndexFlags nIndex, void* dwNewLong) -> void*
6162
static PInvoke.User32.SystemParametersInfoForDpi(PInvoke.User32.SystemParametersInfoAction uiAction, int uiParam, System.IntPtr pvParam, PInvoke.User32.SystemParametersInfoFlags fWinIni, int dpi) -> bool
6263
static PInvoke.User32.mouse_event(PInvoke.User32.mouse_eventFlags dwFlags, int dx, int dy, int dwData, System.IntPtr dwExtraInfo) -> void
64+
static extern PInvoke.User32.AdjustWindowRectEx(PInvoke.RECT* lpRect, PInvoke.User32.WindowStyles dwStyle, bool bMenu, PInvoke.User32.WindowStylesEx dwExStyle) -> bool
6365
static extern PInvoke.User32.AdjustWindowRectExForDpi(PInvoke.RECT* lpRect, PInvoke.User32.WindowStyles dwStyle, bool bMenu, PInvoke.User32.WindowStylesEx dwExStyle, int dpi) -> bool
6466
static extern PInvoke.User32.AreDpiAwarenessContextsEqual(System.IntPtr dpiContextA, System.IntPtr dpiContextB) -> bool
6567
static extern PInvoke.User32.DestroyWindow(System.IntPtr hWnd) -> bool

src/User32/User32.cs

+49-1
Original file line numberDiff line numberDiff line change
@@ -3320,6 +3320,54 @@ public static extern DPI_HOSTING_BEHAVIOR SetThreadDpiHostingBehavior(
33203320
public static extern DPI_HOSTING_BEHAVIOR GetWindowDpiHostingBehavior(
33213321
IntPtr hwnd);
33223322

3323+
/// <summary>
3324+
/// Calculates the required size of the window rectangle, based on the desired size of the client rectangle.
3325+
/// The window rectangle can then be passed to the CreateWindowEx function to create a window whose client area
3326+
/// is the desired size.
3327+
/// </summary>
3328+
/// <param name="lpRect">
3329+
/// A pointer to a RECT structure that contains the coordinates of the top-left and bottom-right corners
3330+
/// of the desired client area. When the function returns, the structure contains the coordinates of the top-left
3331+
/// and bottom-right corners of the window to accommodate the desired client area.
3332+
/// </param>
3333+
/// <param name="dwStyle">
3334+
/// The window style of the window whose required size is to be calculated. Note that you cannot specify
3335+
/// the <see cref="WindowStyles.WS_OVERLAPPED"/> style.</param>
3336+
/// <param name="bMenu">Indicates whether the window has a menu.</param>
3337+
/// <param name="dwExStyle">The extended window style of the window whose required size is to be calculated.</param>
3338+
/// <returns>
3339+
/// If the function succeeds, the return value is true.
3340+
/// If the function fails, the return value is false.
3341+
/// To get extended error information, call GetLastError.
3342+
/// </returns>
3343+
/// <remarks>
3344+
/// <para>
3345+
/// A client rectangle is the smallest rectangle that completely encloses a client area.
3346+
/// A window rectangle is the smallest rectangle that completely encloses the window, which includes
3347+
/// the client area and the nonclient area.
3348+
/// </para>
3349+
/// <para>
3350+
/// The AdjustWindowRectEx function does not add extra space when a menu bar wraps to two or more rows.
3351+
/// </para>
3352+
/// <para>
3353+
/// The AdjustWindowRectEx function does not take the <see cref="WindowStyles.WS_VSCROLL"/> or
3354+
/// <see cref="WindowStyles.WS_HSCROLL"/> styles into account.
3355+
/// To account for the scroll bars, call the GetSystemMetrics function with <see cref="SystemMetric.SM_CXVSCROLL"/> or
3356+
/// <see cref="SystemMetric.SM_CYHSCROLL"/>.
3357+
/// </para>
3358+
/// <para>
3359+
/// This API is not DPI aware, and should not be used if the calling thread is per-monitor DPI aware.
3360+
/// For the DPI-aware version of this API, see AdjustWindowsRectExForDPI.
3361+
/// </para>
3362+
/// </remarks>
3363+
[DllImport(nameof(User32), SetLastError = true)]
3364+
[return:MarshalAs(UnmanagedType.Bool)]
3365+
public static unsafe extern bool AdjustWindowRectEx(
3366+
RECT* lpRect,
3367+
WindowStyles dwStyle,
3368+
[MarshalAs(UnmanagedType.Bool)] bool bMenu,
3369+
WindowStylesEx dwExStyle);
3370+
33233371
/// <summary>
33243372
/// The BeginPaint function prepares the specified window for painting and fills a <see cref="PAINTSTRUCT"/> structure with information about the painting.
33253373
/// </summary>
@@ -3589,7 +3637,7 @@ private static unsafe extern IntPtr CreateWindowEx(
35893637
/// When compiling for 32-bit Windows, SetWindowLongPtr is defined as a call to the SetWindowLong function. This
35903638
/// function is exposed using a helper that conditionally calls SetWindowLong in 32-bit processes.
35913639
/// </remarks>
3592-
[DllImport(nameof(User32), SetLastError = true, EntryPoint = nameof(SetWindowLongPtr))]
3640+
[DllImport(nameof(User32), SetLastError = true, EntryPoint = "SetWindowLongPtr")]
35933641
private static extern unsafe void* SetWindowLongPtr64(IntPtr hWnd, WindowLongIndexFlags nIndex, void* dwNewLong);
35943642
}
35953643
}

0 commit comments

Comments
 (0)