23 #if SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP && SILICONSTUDIO_PARADOX_GRAPHICS_API_DIRECT3D
25 using System.Runtime.InteropServices;
26 using System.Security;
31 namespace SiliconStudio.
Paradox.Games
36 internal class Win32Native
39 [DllImport(
"user32.dll", EntryPoint =
"PeekMessage")]
40 [SuppressUnmanagedCodeSecurity]
41 public static extern int PeekMessage(
42 out NativeMessage lpMsg,
48 [DllImport(
"user32.dll", EntryPoint =
"GetMessage")]
49 [SuppressUnmanagedCodeSecurity]
50 public static extern int GetMessage(
51 out NativeMessage lpMsg,
56 [DllImport(
"user32.dll", EntryPoint =
"TranslateMessage")]
57 [SuppressUnmanagedCodeSecurity]
58 public static extern int TranslateMessage(ref NativeMessage lpMsg);
60 [DllImport(
"user32.dll", EntryPoint =
"DispatchMessage")]
61 [SuppressUnmanagedCodeSecurity]
62 public static extern int DispatchMessage(ref NativeMessage lpMsg);
64 public enum WindowLongType :
int
70 ExtendedStyle = (-20),
75 public delegate IntPtr WndProc(IntPtr hWnd,
int msg, IntPtr wParam, IntPtr lParam);
77 public static IntPtr GetWindowLong(HandleRef hWnd, WindowLongType index)
81 return GetWindowLong32(hWnd, index);
83 return GetWindowLong64(hWnd, index);
86 [DllImport(
"user32.dll", EntryPoint =
"GetFocus", CharSet = CharSet.Unicode)]
87 public static extern IntPtr GetFocus();
89 [DllImport(
"user32.dll", EntryPoint =
"GetWindowLong", CharSet = CharSet.Unicode)]
90 private static extern IntPtr GetWindowLong32(HandleRef hwnd, WindowLongType index);
92 [DllImport(
"user32.dll", EntryPoint =
"GetWindowLongPtr", CharSet = CharSet.Unicode)]
93 private static extern IntPtr GetWindowLong64(HandleRef hwnd, WindowLongType index);
95 public static IntPtr SetWindowLong(HandleRef hwnd, WindowLongType index, IntPtr wndProcPtr)
99 return SetWindowLong32(hwnd, index, wndProcPtr);
101 return SetWindowLongPtr64(hwnd, index, wndProcPtr);
104 [DllImport(
"user32.dll", EntryPoint =
"SetParent", CharSet = CharSet.Unicode)]
105 public static extern IntPtr SetParent(HandleRef hWnd, IntPtr hWndParent);
107 [DllImport(
"user32.dll", EntryPoint =
"SetWindowLong", CharSet = CharSet.Unicode)]
108 private static extern IntPtr SetWindowLong32(HandleRef hwnd, WindowLongType index, IntPtr wndProc);
111 public static bool ShowWindow(HandleRef hWnd,
bool windowVisible)
113 return ShowWindow(hWnd, windowVisible ? 1 : 0);
116 [DllImport(
"user32.dll", EntryPoint =
"ShowWindow", CharSet = CharSet.Unicode)]
117 private static extern bool ShowWindow(HandleRef hWnd,
int mCmdShow);
119 [DllImport(
"user32.dll", EntryPoint =
"SetWindowLongPtr", CharSet = CharSet.Unicode)]
120 private static extern IntPtr SetWindowLongPtr64(HandleRef hwnd, WindowLongType index, IntPtr wndProc);
122 [DllImport(
"user32.dll", EntryPoint =
"CallWindowProc", CharSet = CharSet.Unicode)]
123 public static extern IntPtr CallWindowProc(IntPtr wndProc, IntPtr hwnd,
int msg, IntPtr wParam, IntPtr lParam);
125 [DllImport(
"user32.dll", EntryPoint =
"GetClientRect")]
126 public static extern bool GetClientRect(IntPtr hWnd, out
Rectangle lpRect);
128 [DllImport(
"kernel32.dll", EntryPoint =
"GetModuleHandle", CharSet = CharSet.Unicode)]
129 public static extern IntPtr GetModuleHandle(
string lpModuleName);
131 public const int WM_SIZE = 0x0005;
133 public const int WM_ACTIVATEAPP = 0x001C;
135 public const int WM_POWERBROADCAST = 0x0218;
137 public const int WM_MENUCHAR = 0x0120;
139 public const int WM_SYSCOMMAND = 0x0112;
141 public const int WM_KEYDOWN = 0x100;
143 public const int WM_KEYUP = 0x101;
145 public const int WM_CHAR = 0x102;
147 public const int WM_SYSKEYDOWN = 0x104;
149 public const int WM_SYSKEYUP = 0x105;
System.Windows.Shapes.Rectangle Rectangle