structs.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Drawing;
  7. using System.Runtime.InteropServices;
  8. namespace PaintDotNet.SystemLayer.FileDlgExtenders.Win32Types
  9. {
  10. #region WINDOWINFO
  11. [StructLayout(LayoutKind.Sequential)]
  12. internal struct WINDOWINFO
  13. {
  14. public UInt32 cbSize;
  15. public RECT rcWindow;
  16. public RECT rcClient;
  17. public UInt32 dwStyle;
  18. public UInt32 dwExStyle;
  19. public UInt32 dwWindowStatus;
  20. public UInt32 cxWindowBorders;
  21. public UInt32 cyWindowBorders;
  22. public UInt16 atomWindowType;
  23. public UInt16 wCreatorVersion;
  24. }
  25. #endregion
  26. #region POINT
  27. [StructLayout(LayoutKind.Sequential)]
  28. internal struct POINT
  29. {
  30. public int x;
  31. public int y;
  32. #region Constructors
  33. public POINT(int x, int y)
  34. {
  35. this.x = x;
  36. this.y = y;
  37. }
  38. public POINT(Point point)
  39. {
  40. x = point.X;
  41. y = point.Y;
  42. }
  43. #endregion
  44. }
  45. #endregion
  46. #region RECT
  47. [StructLayout(LayoutKind.Sequential)]
  48. internal struct RECT
  49. {
  50. public int left;
  51. public int top;
  52. public int right;
  53. public int bottom;
  54. #region Properties
  55. public POINT Location
  56. {
  57. get { return new POINT((int)left, (int)top); }
  58. set
  59. {
  60. right -= (left - value.x);
  61. bottom -= (bottom - value.y);
  62. left = value.x;
  63. top = value.y;
  64. }
  65. }
  66. internal uint Width
  67. {
  68. get { return (uint)Math.Abs(right - left); }
  69. set { right = left + (int)value; }
  70. }
  71. internal uint Height
  72. {
  73. get { return (uint)Math.Abs(bottom - top); }
  74. set { bottom = top + (int)value; }
  75. }
  76. #endregion
  77. #region Overrides
  78. public override string ToString()
  79. {
  80. return left + ":" + top + ":" + right + ":" + bottom;
  81. }
  82. #endregion
  83. }
  84. #endregion
  85. #region WINDOWPOS
  86. [StructLayout(LayoutKind.Sequential)]
  87. internal struct WINDOWPOS
  88. {
  89. public IntPtr hwnd;
  90. public IntPtr hwndAfter;
  91. public int x;
  92. public int y;
  93. public int cx;
  94. public int cy;
  95. public uint flags;
  96. #region Overrides
  97. public override string ToString()
  98. {
  99. return x + ":" + y + ":" + cx + ":" + cy + ":" + ((SWP_Flags)flags).ToString();
  100. }
  101. #endregion
  102. }
  103. #endregion
  104. //#region NCCALCSIZE_PARAMS
  105. //internal struct NCCALCSIZE_PARAMS
  106. //{
  107. // public RECT rgrc1;
  108. // public RECT rgrc2;
  109. // public RECT rgrc3;
  110. // public IntPtr lppos;
  111. //}
  112. //#endregion
  113. #region NMHDR
  114. [StructLayout(LayoutKind.Sequential)]
  115. internal struct NMHDR
  116. {
  117. public IntPtr hwndFrom;
  118. public IntPtr idFrom;
  119. public uint code;
  120. }
  121. #endregion
  122. #region NMHEADER
  123. [StructLayout(LayoutKind.Sequential)]
  124. internal struct NMHEADER
  125. {
  126. internal NMHDR hdr;
  127. internal int iItem;
  128. internal int iButton;
  129. internal IntPtr pItem;
  130. }
  131. #endregion
  132. #region OPENFILENAME
  133. /// <summary>
  134. /// Defines the shape of hook procedures that can be called by the OpenFileDialog
  135. /// </summary>
  136. internal delegate IntPtr OfnHookProc(IntPtr hWnd, UInt16 msg, Int32 wParam, Int32 lParam);
  137. /// <summary>
  138. /// See the documentation for OPENFILENAME
  139. /// </summary>
  140. //typedef struct tagOFN {
  141. // DWORD lStructSize;
  142. // HWND hwndOwner;
  143. // HINSTANCE hInstance;
  144. // LPCTSTR lpstrFilter;
  145. // LPTSTR lpstrCustomFilter;
  146. // DWORD nMaxCustFilter;
  147. // DWORD nFilterIndex;
  148. // LPTSTR lpstrFile;
  149. // DWORD nMaxFile;
  150. // LPTSTR lpstrFileTitle;
  151. // DWORD nMaxFileTitle;
  152. // LPCTSTR lpstrInitialDir;
  153. // LPCTSTR lpstrTitle;
  154. // DWORD Flags;
  155. // WORD nFileOffset;
  156. // WORD nFileExtension;
  157. // LPCTSTR lpstrDefExt;
  158. // LPARAM lCustData;
  159. // LPOFNHOOKPROC lpfnHook;
  160. // LPCTSTR lpTemplateName;
  161. //#if (_WIN32_WINNT >= 0x0500)
  162. // void * pvReserved;
  163. // DWORD dwReserved;
  164. // DWORD FlagsEx;
  165. //#endif // (_WIN32_WINNT >= 0x0500)
  166. //} OPENFILENAME, *LPOPENFILENAME;
  167. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
  168. internal struct OPENFILENAME
  169. {
  170. public UInt32 lStructSize;
  171. public IntPtr hwndOwner;
  172. public IntPtr hInstance;
  173. public String lpstrFilter;
  174. public String lpstrCustomFilter;
  175. public UInt32 nMaxCustFilter;
  176. public Int32 nFilterIndex;
  177. public String lpstrFile;
  178. public UInt32 nMaxFile;
  179. public String lpstrFileTitle;
  180. public UInt32 nMaxFileTitle;
  181. public String lpstrInitialDir;
  182. public String lpstrTitle;
  183. public UInt32 Flags;
  184. public UInt16 nFileOffset;
  185. public UInt16 nFileExtension;
  186. public String lpstrDefExt;
  187. public IntPtr lCustData;
  188. public OfnHookProc lpfnHook;
  189. public String lpTemplateName;
  190. public IntPtr pvReserved;
  191. public UInt32 dwReserved;
  192. public UInt32 FlagsEx;
  193. };
  194. #endregion
  195. #region OFNOTIFY
  196. [StructLayout(LayoutKind.Sequential)]
  197. internal struct OFNOTIFY
  198. {
  199. public NMHDR hdr;
  200. public IntPtr OpenFileName;
  201. public IntPtr fileNameShareViolation;
  202. }
  203. #endregion
  204. }