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