1 /// <summary>
2 /// Get Desktop Window
3 /// </summary>
4 /// <returns></returns>
5 [DllImport("")]
6 public static extern IntPtr GetDesktopWindow();
7 /// <summary>
8 /// Get the rectangular area of the entire window
9 /// </summary>
10 /// <returns></returns>
11 [DllImport("", SetLastError = true)]
12 public static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);
13 /// <summary>
14 /// Retrieve the device context for the entire window
15 /// </summary>
16 /// <param name="hWnd">Handle to the window with the device context to be retrieved</param>
17 /// <returns></returns>
18 [DllImport("", SetLastError = true)]
19 public static extern IntPtr GetWindowDC(IntPtr hWnd);
20 /// <summary>
21 /// Creates a memory device context compatible with the specified device
22 /// </summary>
23 /// <param name="hdc">Handle to an existing DC</param>
24 /// <returns>If the function succeeds, the return value is a handle to the memory DC, otherwise it returns Null.</returns>
25 [DllImport("")]
26 public static extern IntPtr CreateCompatibleDC([In] IntPtr hdc);
27 /// <summary>
28 /// Selects the object into the specified device context
29 /// </summary>
30 /// <param name="hdc">Handle to DC</param>
31 /// <param name="gdiObj">Handle of the object to be selected</param>
32 /// <returns>If the function succeeds, the return value is a handle to a compatible bitmap (DDB), otherwise it returns Null.</returns>
33 [DllImport("")]
34 public static extern IntPtr SelectObject([In] IntPtr hdc, [In] IntPtr gdiObj);
35 /// <summary>
36 /// Creates a bitmap of the device associated with the specified device context
37 /// </summary>
38 /// <param name="hdc">Handle to the device context</param>
39 /// <param name="nWidth">Bitmap width in pixels</param>
40 /// <param name="nHeight">Bitmap height in pixels</param>
41 /// <returns></returns>
42 [DllImport("")]
43 public static extern IntPtr CreateCompatibleBitmap([In] IntPtr hdc, int nWidth, int nHeight);
44 /// <summary>
45 /// Performs a bit-block transfer of color data corresponding to a pixel rectangle from a specified source device context to a target device context
46 /// </summary>
47 /// <param name="hdcDest">Handle to the target device context</param>
48 /// <param name="xDest">x-coordinate of the upper left corner of the target rectangle (in logical units)</param>
49 /// <param name="yDest">y-coordinate of the upper left corner of the target rectangle (in logical units)</param>
50 /// <param name="wDest">Width of source and target rectangles (logical units)</param>
51 /// <param name="hDest">Height of source and target rectangles (logical units)</param>
52 /// <param name="hdcSource">The handle to the source device context</param>
53 /// <param name="xSrc">x-coordinate of the upper left corner of the source rectangle (in logical units)</param>
54 /// <param name="ySrc">y-coordinate of the upper left corner of the source rectangle (in logical units)</param>
55 /// <param name="rop">Define how to combine the color data of the source rectangle with the color data of the target rectangle</param>
56 /// <returns></returns>
57 [DllImport("")]
58 public static extern bool BitBlt(IntPtr hdcDest,
59 int xDest, int yDest, int wDest, int hDest, IntPtr hdcSource,
60 int xSrc, int ySrc, CopyPixelOperation rop);
61 /// <summary>
62 /// Deletes logical pens, brushes, fonts, bitmaps, regions, or color palettes, freeing all system resources associated with the object.
63 /// When the object is deleted, the specified handle will no longer be valid.
64 /// </summary>
65 /// <param name="hObject"></param>
66 /// <returns></returns>
67 [DllImport("")]
68 public static extern bool DeleteObject(IntPtr hObject);
69 /// <summary>
70 /// Delete the specified device context
71 /// </summary>
72 /// <param name="hdc">Sentences in the context of the device Sentences in the context of the device</param>
73 /// <returns></returns>
74 [DllImport("")]
75 public static extern bool DeleteDC([In] IntPtr hdc);
76 /// <summary>
77 /// Release the device context (DC), freeing it for use by other applications
78 /// </summary>
79 /// <param name="hWnd"></param>
80 /// <param name="hdc"></param>
81 /// <returns></returns>
82 [DllImport("", SetLastError = true)]
83 public static extern bool ReleaseDC(IntPtr hWnd, IntPtr hdc);
84
85 /// <summary>
86 /// Defines a rectangular area.
87 /// </summary>
88 [StructLayout()]
89 public struct RECT
90 {
91 /// <summary>
92 /// The X coordinate of the left side of the rectangle.
93 /// </summary>
94 public int Left;
95
96 /// <summary>
97 /// The y-coordinate of the top of the rectangle.
98 /// </summary>
99 public int Top;
100
101 /// <summary>
102 /// The X coordinate of the right side of the rectangle.
103 /// </summary>
104 public int Right;
105
106 /// <summary>
107 /// The y-coordinate of the bottom of the rectangle.
108 /// </summary>
109 public int Bottom;
110
111 /// <summary>
112 /// Gets the width of the rectangle.
113 /// </summary>
114 public int Width => Right - Left;
115
116 /// <summary>
117 /// Gets the height of the rectangle.
118 /// </summary>
119 public int Height => Bottom - Top;
120
121 /// <summary>
122 /// Initialize a new rectangle.
123 /// </summary>
124 /// <param name="left">The X coordinate of the left side of the rectangle.</param>
125 /// <param name="top">The y-coordinate of the top of the rectangle.</param>
126 /// <param name="right">The X coordinate of the right side of the rectangle.</param>
127 /// <param name="bottom">The y-coordinate of the bottom of the rectangle.</param>
128 public RECT(int left, int top, int right, int bottom)
129 {
130 Left = left;
131 Top = top;
132 Right = right;
133 Bottom = bottom;
134 }
135 }