Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
NativeHelper.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 #if SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP
4 using System;
5 using System.Runtime.InteropServices;
6 using System.Windows;
7 
8 namespace SiliconStudio.Presentation.Extensions
9 {
10  public static class NativeHelper
11  {
12  #region Methods
13 
14  [DllImport("user32.dll")]
15  [return: MarshalAs(UnmanagedType.Bool)]
16  public static extern bool SetCursorPos(int x, int y);
17 
18  [DllImport("user32.dll")]
19  public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
20 
21  [DllImport("user32.dll", SetLastError = true)]
22  public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
23 
24  [DllImport("user32.dll")]
25  public static extern IntPtr SetParent(IntPtr hWnd, IntPtr hWndParent);
26 
27  [DllImport("user32.dll", SetLastError = true)]
28  public static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);
29 
30  [DllImport("user32.dll", SetLastError = true)]
31  public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
32 
33  [DllImport("user32.dll")]
34  public static extern bool ShowWindow(IntPtr hWnd, int mCmdShow);
35 
36  [DllImport("user32.dll")]
37  public static extern IntPtr MonitorFromWindow(IntPtr hwnd, int dwFlags);
38 
39  [DllImport("user32.dll")]
40  public static extern bool GetMonitorInfo(IntPtr hmonitor, [In, Out] MONITORINFO monitorInfo);
41 
42  #endregion Methods
43 
44  #region Structures
45 
46  // ReSharper disable InconsistentNaming
47 
48  [StructLayout(LayoutKind.Sequential)]
49  public struct MINMAXINFO
50  {
51  public POINT ptReserved;
52  public POINT ptMaxSize;
53  public POINT ptMaxPosition;
54  public POINT ptMinTrackSize;
55  public POINT ptMaxTrackSize;
56  }
57 
58  [StructLayout(LayoutKind.Sequential)]
59  public class MONITORINFO
60  {
61  public int cbSize = sizeof(int) * 10;
62  public RECT rcMonitor;
63  public RECT rcWork;
64  public int dwFlags;
65  }
66 
67  [StructLayout(LayoutKind.Sequential)]
68  public struct POINT
69  {
70  public int X, Y;
71 
72  public POINT(int x, int y)
73  {
74  X = x;
75  Y = y;
76  }
77  }
78 
79  [StructLayout(LayoutKind.Sequential)]
80  public struct RECT
81  {
82  public int Left, Top, Right, Bottom;
83 
84  public RECT(int left, int top, int right, int bottom)
85  {
86  Left = left;
87  Top = top;
88  Right = right;
89  Bottom = bottom;
90  }
91  }
92 
93  #endregion Structures
94 
95  #region Constants
96 
97  public const int GWL_STYLE = unchecked((int)0xFFFFFFF0);
98 
99  public const int MONITOR_DEFAULTTONULL = unchecked(0x00000000);
100  public const int MONITOR_DEFAULTTOPRIMARY = unchecked(0x00000001);
101  public const int MONITOR_DEFAULTTONEAREST = unchecked(0x00000002);
102 
103  // Window Styles - http://msdn.microsoft.com/en-us/library/windows/desktop/ms632600%28v=vs.85%29.aspx
104  public const int WS_BORDER = unchecked(0x00800000);
105  public const int WS_CAPTION = unchecked(0x00C00000);
106  public const int WS_CHILD = unchecked(0x40000000);
107  public const int WS_CHILDWINDOW = unchecked(0x40000000);
108  public const int WS_CLIPCHILDREN = unchecked(0x02000000);
109  public const int WS_CLIPSIBLINGS = unchecked(0x04000000);
110  public const int WS_DISABLED = unchecked(0x08000000);
111  public const int WS_DLGFRAME = unchecked(0x00400000);
112  public const int WS_GROUP = unchecked(0x00020000);
113  public const int WS_HSCROLL = unchecked(0x00100000);
114  public const int WS_ICONIC = unchecked(0x20000000);
115  public const int WS_MAXIMIZE = unchecked(0x01000000);
116  public const int WS_MAXIMIZEBOX = unchecked(0x00010000);
117  public const int WS_MINIMIZE = unchecked(0x20000000);
118  public const int WS_MINIMIZEBOX = unchecked(0x00020000);
119  public const int WS_OVERLAPPED = unchecked(0x00000000);
120  public const int WS_OVERLAPPEDWINDOW = unchecked(WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
121  public const int WS_POPUP = unchecked((int)0x80000000);
122  public const int WS_POPUPWINDOW = unchecked(WS_POPUP | WS_BORDER | WS_SYSMENU);
123  public const int WS_SIZEBOX = unchecked(0x00040000);
124  public const int WS_SYSMENU = unchecked(0x00080000);
125  public const int WS_TABSTOP = unchecked(0x00010000);
126  public const int WS_THICKFRAME = unchecked(0x00040000);
127  public const int WS_TILED = unchecked(0x00000000);
128  public const int WS_TILEDWINDOW = unchecked(WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
129  public const int WS_VISIBLE = unchecked(0x10000000);
130  public const int WS_VSCROLL = unchecked(0x00200000);
131 
132  public const int SW_HIDE = unchecked(0x00000000);
133  // ReSharper restore InconsistentNaming
134 
135  #endregion Constants
136 
137  public static bool SetCursorPos(Point pt)
138  {
139  return SetCursorPos((int)pt.X, (int)pt.Y);
140  }
141  }
142 }
143 #endif
_In_ size_t _In_ DXGI_FORMAT _In_ size_t _In_ float size_t y
Definition: DirectXTexP.h:191
The child element is aligned to the bottom of the parent's layout slot.
The child element is aligned to the top of the parent's layout slot.
System.Windows.Point Point
Definition: ColorPicker.cs:15