forked from Rampastring/Rampastring.XNAUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNativeMethods.cs
119 lines (112 loc) · 9.59 KB
/
NativeMethods.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
/* SetWindowLongPtr only exists on 64bit Windows versions. The code generator only generates this method when the Platform is set to a 64bit Platform.
* We copy the generated code here so we can build for AnyCPU.
* By default SetWindowLongW is generated, XNA needs SetWindowLongA
* CallWindowProc needs to use the XNA defined delegate */
#pragma warning disable CS1591,CS1573,CS0465,CS0649,CS8019,CS1570,CS1584,CS1658,CS0436,CS8981
namespace Windows.Win32
{
using global::System;
using global::System.Diagnostics;
using global::System.Runtime.CompilerServices;
using global::System.Runtime.InteropServices;
using global::System.Runtime.Versioning;
using winmdroot = global::Windows.Win32;
/// <content>
/// Contains extern methods from "User32.dll".
/// </content>
internal static partial class PInvoke
{
/// <summary>Changes an attribute of the specified window.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window and, indirectly, the class to which the window belongs. The <b>SetWindowLongPtr</b> function fails if the process that owns the window specified by the <i>hWnd</i> parameter is at a higher process privilege in the UIPI hierarchy than the process the calling thread resides in. <b>Windows XP/2000: </b> The <b>SetWindowLongPtr</b> function fails if the window specified by the <i>hWnd</i> parameter does not belong to the same process as the calling thread.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//winuser/nf-winuser-setwindowlongptrw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="nIndex">Type: <b>int</b></param>
/// <param name="dwNewLong">
/// <para>Type: <b>LONG_PTR</b> The replacement value.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//winuser/nf-winuser-setwindowlongptrw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>LONG_PTR</b> If the function succeeds, the return value is the previous value of the specified offset. If the function fails, the return value is zero. To get extended error information, call <a href="/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>. If the previous value is zero and the function succeeds, the return value is zero, but the function does not clear the last error information. To determine success or failure, clear the last error information by calling <a href="/windows/desktop/api/errhandlingapi/nf-errhandlingapi-setlasterror">SetLastError</a> with 0, then call <b>SetWindowLongPtr</b>. Function failure will be indicated by a return value of zero and a <a href="/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a> result that is nonzero.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//winuser/nf-winuser-setwindowlongptrw">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("User32", ExactSpelling = true, EntryPoint = "SetWindowLongPtrW", SetLastError = true)]
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
#if NET5_0_OR_GREATER
[SupportedOSPlatform("windows5.0")]
#endif
internal static extern nint SetWindowLongPtr(winmdroot.Foundation.HWND hWnd, winmdroot.UI.WindowsAndMessaging.WINDOW_LONG_PTR_INDEX nIndex, nint dwNewLong);
/// <summary>Changes an attribute of the specified window. The function also sets the 32-bit (long) value at the specified offset into the extra window memory.</summary>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window and, indirectly, the class to which the window belongs.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//winuser/nf-winuser-setwindowlongw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="nIndex">Type: <b>int</b></param>
/// <param name="dwNewLong">
/// <para>Type: <b>LONG</b> The replacement value.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//winuser/nf-winuser-setwindowlongw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>LONG</b> If the function succeeds, the return value is the previous value of the specified 32-bit integer. If the function fails, the return value is zero. To get extended error information, call <a href="/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a>. If the previous value of the specified 32-bit integer is zero, and the function succeeds, the return value is zero, but the function does not clear the last error information. This makes it difficult to determine success or failure. To deal with this, you should clear the last error information by calling <a href="/windows/desktop/api/errhandlingapi/nf-errhandlingapi-setlasterror">SetLastError</a> with 0 before calling <b>SetWindowLong</b>. Then, function failure will be indicated by a return value of zero and a <a href="/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror">GetLastError</a> result that is nonzero.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//winuser/nf-winuser-setwindowlongw">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("User32", ExactSpelling = true, EntryPoint = "SetWindowLongA", SetLastError = true)]
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
#if NET5_0_OR_GREATER
[SupportedOSPlatform("windows5.0")]
#endif
internal static extern int SetWindowLong(winmdroot.Foundation.HWND hWnd, winmdroot.UI.WindowsAndMessaging.WINDOW_LONG_PTR_INDEX nIndex, int dwNewLong);
/// <summary>Passes message information to the specified window procedure.</summary>
/// <param name="lpPrevWndFunc">
/// <para>Type: <b>WNDPROC</b> The previous window procedure. If this value is obtained by calling the <a href="https://docs.microsoft.com/windows/desktop/api/winuser/nf-winuser-getwindowlonga">GetWindowLong</a> function with the <i>nIndex</i> parameter set to <b>GWL_WNDPROC</b> or <b>DWL_DLGPROC</b>, it is actually either the address of a window or dialog box procedure, or a special internal value meaningful only to <b>CallWindowProc</b>.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//winuser/nf-winuser-callwindowprocw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="hWnd">
/// <para>Type: <b>HWND</b> A handle to the window procedure to receive the message.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//winuser/nf-winuser-callwindowprocw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="Msg">
/// <para>Type: <b>UINT</b> The message.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//winuser/nf-winuser-callwindowprocw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="wParam">
/// <para>Type: <b>WPARAM</b> Additional message-specific information. The contents of this parameter depend on the value of the <i>Msg</i> parameter.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//winuser/nf-winuser-callwindowprocw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <param name="lParam">
/// <para>Type: <b>LPARAM</b> Additional message-specific information. The contents of this parameter depend on the value of the <i>Msg</i> parameter.</para>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//winuser/nf-winuser-callwindowprocw#parameters">Read more on docs.microsoft.com</see>.</para>
/// </param>
/// <returns>
/// <para>Type: <b>LRESULT</b> The return value specifies the result of the message processing and depends on the message sent.</para>
/// </returns>
/// <remarks>
/// <para><see href="https://docs.microsoft.com/windows/win32/api//winuser/nf-winuser-callwindowprocw">Learn more about this API from docs.microsoft.com</see>.</para>
/// </remarks>
[DllImport("User32", ExactSpelling = true, EntryPoint = "CallWindowProcW")]
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
#if NET5_0_OR_GREATER
[SupportedOSPlatform("windows5.0")]
#endif
internal static extern IntPtr CallWindowProc(UI.WindowsAndMessaging.WndProcDelegate lpPrevWndFunc, IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
}
namespace UI.WindowsAndMessaging
{
// Microsoft.Xna.Framework.Input.WindowMessageHooker.Hook.WndProcDelegate:
// private delegate IntPtr WndProcDelegate(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
[UnmanagedFunctionPointerAttribute(CallingConvention.Winapi)]
internal unsafe delegate IntPtr WndProcDelegate(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
}
}