Adding bitmap field object.
1 //=============================================================================
2 // COPYRIGHT: Prosoft-Lanz
3 //=============================================================================
5 // $Workfile: Win32API.cs $
7 // PROJECT : CodeProject Components
9 // CREATION : 19.02.2003
12 // DETAILS : This class implement Win32 API calls
13 // and the contants used for these calls.
15 //-----------------------------------------------------------------------------
19 using System.Windows.Forms;
20 using System.Runtime.InteropServices;
22 namespace CodeProject.Win32API
24 ///////////////////////////////////////////////////////////////////////
25 #region Generic declarations
28 /// Rectangle parameters exposed as a structure.
33 /// Rectangle members.
35 public int left, top, right, bottom;
40 ///////////////////////////////////////////////////////////////////////
44 /// Utility functions.
46 public sealed class API
48 private API() {} // To remove the constructor from the documentation!
51 /// Get true multiscreen size.
53 public static Rectangle TrueScreenRect
57 // get the biggest screen area
58 Rectangle rectScreen = Screen.PrimaryScreen.WorkingArea;
59 int left = rectScreen.Left;
60 int top = rectScreen.Top;
61 int right = rectScreen.Right;
62 int bottom = rectScreen.Bottom;
63 foreach (Screen screen in Screen.AllScreens)
65 left = Math.Min(left, screen.WorkingArea.Left);
66 right = Math.Max(right, screen.WorkingArea.Right);
67 top = Math.Min(top, screen.WorkingArea.Top);
68 bottom = Math.Max(bottom, screen.WorkingArea.Bottom);
70 return new Rectangle(left, top, right-left, bottom-top);
77 ///////////////////////////////////////////////////////////////////////
81 /// Class to expose USER32 API functions.
83 public sealed class USER32
85 private USER32() {} // To remove the constructor from the documentation!
87 [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
88 internal static extern int GetWindowRect(IntPtr hWnd, ref RECT rect);
90 [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
91 internal static extern int MoveWindow(IntPtr hWnd, int x, int y, int w, int h, int repaint);
93 [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
94 internal static extern IntPtr GetActiveWindow();
96 [DllImport("user32", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
97 internal static extern int GetClassName(IntPtr hwnd, StringBuilder lpClassName, int nMaxCount);