diff -r 19c1aaf900dc -r 7acec5059fa6 Server/Win32API.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Server/Win32API.cs Tue Aug 12 20:55:50 2014 +0200 @@ -0,0 +1,100 @@ +//============================================================================= +// COPYRIGHT: Prosoft-Lanz +//============================================================================= +// +// $Workfile: Win32API.cs $ +// +// PROJECT : CodeProject Components +// VERSION : 1.00 +// CREATION : 19.02.2003 +// AUTHOR : JCL +// +// DETAILS : This class implement Win32 API calls +// and the contants used for these calls. +// +//----------------------------------------------------------------------------- +using System; +using System.Text; +using System.Drawing; +using System.Windows.Forms; +using System.Runtime.InteropServices; + +namespace CodeProject.Win32API +{ + /////////////////////////////////////////////////////////////////////// + #region Generic declarations + + /// + /// Rectangle parameters exposed as a structure. + /// + public struct RECT + { + /// + /// Rectangle members. + /// + public int left, top, right, bottom; + } + + #endregion + + /////////////////////////////////////////////////////////////////////// + #region Util class + + /// + /// Utility functions. + /// + public sealed class API + { + private API() {} // To remove the constructor from the documentation! + + /// + /// Get true multiscreen size. + /// + public static Rectangle TrueScreenRect + { + get + { + // get the biggest screen area + Rectangle rectScreen = Screen.PrimaryScreen.WorkingArea; + int left = rectScreen.Left; + int top = rectScreen.Top; + int right = rectScreen.Right; + int bottom = rectScreen.Bottom; + foreach (Screen screen in Screen.AllScreens) + { + left = Math.Min(left, screen.WorkingArea.Left); + right = Math.Max(right, screen.WorkingArea.Right); + top = Math.Min(top, screen.WorkingArea.Top); + bottom = Math.Max(bottom, screen.WorkingArea.Bottom); + } + return new Rectangle(left, top, right-left, bottom-top); + } + } + } + + #endregion + + /////////////////////////////////////////////////////////////////////// + #region USER32 class + + /// + /// Class to expose USER32 API functions. + /// + public sealed class USER32 + { + private USER32() {} // To remove the constructor from the documentation! + + [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + internal static extern int GetWindowRect(IntPtr hWnd, ref RECT rect); + + [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + internal static extern int MoveWindow(IntPtr hWnd, int x, int y, int w, int h, int repaint); + + [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + internal static extern IntPtr GetActiveWindow(); + + [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] + internal static extern int GetClassName(IntPtr hwnd, StringBuilder lpClassName, int nMaxCount); + } + #endregion +}