Structs.cs
Upload User: nnpulika
Upload Date: 2013-02-15
Package Size: 597k
Code Size: 15k
Category:

StatusBar

Development Platform:

C#

  1. using System;
  2. using System.Drawing;
  3. using System.Runtime.InteropServices;
  4. using System.Text;
  5. using System.Diagnostics;
  6. namespace UtilityLibrary.Win32
  7. {
  8. /// <summary>
  9. /// Structures to interoperate with the Windows 32 API  
  10. /// </summary>
  11.   #region SIZE
  12. [StructLayout(LayoutKind.Sequential)]
  13. public struct SIZE
  14. {
  15. public int cx;
  16. public int cy;
  17. }
  18. #endregion
  19. #region RECT
  20. [StructLayout(LayoutKind.Sequential)]
  21. public struct RECT
  22. {
  23. public int left;
  24. public int top;
  25. public int right;
  26. public int bottom;
  27. }
  28. #endregion
  29. #region INITCOMMONCONTROLSEX
  30. [StructLayout(LayoutKind.Sequential, Pack=1)]
  31. public class INITCOMMONCONTROLSEX 
  32. {
  33. public int dwSize;
  34. public CommonControlInitFlags dwICC;
  35. }
  36. #endregion
  37. #region TBBUTTON
  38. [StructLayout(LayoutKind.Sequential, Pack=1)]
  39. public struct TBBUTTON 
  40. {
  41. public int iBitmap;
  42. public int idCommand;
  43. public byte fsState;
  44. public byte fsStyle;
  45. public byte bReserved0;
  46. public byte bReserved1;
  47. public int dwData;
  48. public int iString;
  49. }
  50. #endregion
  51. #region POINT
  52. [StructLayout(LayoutKind.Sequential)]
  53. public struct POINT
  54. {
  55. public int x;
  56. public int y;
  57. }
  58. #endregion
  59. #region NMHDR
  60. [StructLayout(LayoutKind.Sequential)]
  61. public struct NMHDR
  62. {
  63. public IntPtr hwndFrom;
  64. public int idFrom;
  65. public int code;
  66. }
  67. #endregion
  68. #region TOOLTIPTEXTA
  69. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
  70. public struct TOOLTIPTEXTA
  71. {
  72. public NMHDR hdr;
  73. public IntPtr lpszText;
  74. [MarshalAs(UnmanagedType.ByValTStr, SizeConst=80)]
  75. public string szText;
  76. public IntPtr hinst;
  77. public ToolTipFlags flags;
  78. }
  79. #endregion
  80. #region TOOLTIPTEXT
  81. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
  82. public struct TOOLTIPTEXT
  83. {
  84. public NMHDR hdr;
  85. public IntPtr lpszText;
  86. [MarshalAs(UnmanagedType.ByValTStr, SizeConst=80)]
  87. public string szText;
  88. public IntPtr hinst;
  89. public int uFlags;
  90. }
  91. #endregion
  92. #region NMCUSTOMDRAW
  93. [StructLayout(LayoutKind.Sequential)]
  94. public struct NMCUSTOMDRAW
  95. {
  96. public NMHDR hdr;
  97. public int dwDrawStage;
  98. public IntPtr hdc;
  99. public RECT rc;
  100. public uint dwItemSpec;
  101. public uint uItemState;
  102. public IntPtr lItemlParam;
  103. }
  104. #endregion
  105. #region NMTBCUSTOMDRAW
  106. [StructLayout(LayoutKind.Sequential)]
  107. public struct NMTBCUSTOMDRAW
  108. {
  109. public NMCUSTOMDRAW nmcd;
  110. public IntPtr hbrMonoDither;
  111. public IntPtr hbrLines;
  112. public IntPtr hpenLines;
  113. public int clrText;
  114. public int clrMark;
  115. public int clrTextHighlight;
  116. public int clrBtnFace;
  117. public int clrBtnHighlight;
  118. public int clrHighlightHotTrack;
  119. public RECT rcText;
  120. public int nStringBkMode;
  121. public int nHLStringBkMode;
  122. }
  123. #endregion
  124. #region NMLVCUSTOMDRAW
  125. [StructLayout(LayoutKind.Sequential)]
  126. public struct NMLVCUSTOMDRAW 
  127. {
  128. public NMCUSTOMDRAW nmcd;
  129. public uint clrText;
  130. public uint clrTextBk;
  131. public int iSubItem;
  132. #endregion
  133. #region TBBUTTONINFO
  134. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
  135. public struct TBBUTTONINFO
  136. {
  137. public int cbSize;
  138. public uint dwMask;
  139. public int idCommand;
  140. public int iImage;
  141. public byte fsState;
  142. public byte fsStyle;
  143. public short cx;
  144. public IntPtr lParam;
  145. public IntPtr pszText;
  146. public int cchText;
  147. }
  148. #endregion
  149. #region REBARBANDINFO
  150. [StructLayout(LayoutKind.Sequential)]
  151. public struct REBARBANDINFO
  152. {
  153. public int cbSize;
  154. public RebarInfoMask fMask;
  155. public RebarStylesEx fStyle;
  156. public int clrFore;
  157. public int clrBack;
  158. public IntPtr lpText;
  159. public int cch;
  160. public int iImage;
  161. public IntPtr hwndChild;
  162. public int cxMinChild;
  163. public int cyMinChild;
  164. public int cx;
  165. public IntPtr hbmBack;
  166. public int wID;
  167. public int cyChild;
  168. public int cyMaxChild;
  169. public int cyIntegral;
  170. public int cxIdeal;
  171. public int lParam;
  172. public int cxHeader;
  173. }
  174. #endregion
  175. #region MOUSEHOOKSTRUCT
  176. [StructLayout(LayoutKind.Sequential)]
  177. public struct MOUSEHOOKSTRUCT 
  178. public POINT     pt; 
  179. public IntPtr    hwnd; 
  180. public int       wHitTestCode; 
  181. public IntPtr    dwExtraInfo; 
  182. }
  183. #endregion
  184. #region NMTOOLBAR
  185. [StructLayout(LayoutKind.Sequential)]
  186. public struct NMTOOLBAR 
  187. {
  188. public NMHDR hdr;
  189. public int     iItem;
  190. public TBBUTTON     tbButton;
  191. public int     cchText;
  192. public IntPtr pszText;
  193. public RECT     rcButton; 
  194. }
  195. #endregion
  196. #region NMREBARCHEVRON
  197. [StructLayout(LayoutKind.Sequential)]
  198. public struct NMREBARCHEVRON
  199. {
  200. public NMHDR hdr;
  201. public int uBand;
  202. public int wID;
  203. public int lParam;
  204. public RECT rc;
  205. public int lParamNM;
  206. }
  207. #endregion
  208. #region BITMAP
  209. [StructLayout(LayoutKind.Sequential)]
  210. public struct BITMAP
  211. {
  212. public long   bmType; 
  213. public long   bmWidth; 
  214. public long   bmHeight; 
  215. public long   bmWidthBytes; 
  216. public short  bmPlanes; 
  217. public short  bmBitsPixel; 
  218. public IntPtr bmBits; 
  219. }
  220. #endregion
  221.  
  222. #region BITMAPINFO_FLAT
  223. [StructLayout(LayoutKind.Sequential)]
  224. public struct BITMAPINFO_FLAT 
  225. {
  226. public int      bmiHeader_biSize;
  227. public int      bmiHeader_biWidth;
  228. public int      bmiHeader_biHeight;
  229. public short    bmiHeader_biPlanes;
  230. public short    bmiHeader_biBitCount;
  231. public int      bmiHeader_biCompression;
  232. public int      bmiHeader_biSizeImage;
  233. public int      bmiHeader_biXPelsPerMeter;
  234. public int      bmiHeader_biYPelsPerMeter;
  235. public int      bmiHeader_biClrUsed;
  236. public int      bmiHeader_biClrImportant;
  237. [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=1024)]
  238. public byte[] bmiColors; 
  239. }
  240. #endregion
  241.     #region RGBQUAD
  242. public struct RGBQUAD 
  243. {
  244. public byte rgbBlue;
  245. public byte rgbGreen;
  246. public byte rgbRed;
  247. public byte rgbReserved;
  248. }
  249. #endregion
  250. #region BITMAPINFOHEADER
  251. [StructLayout(LayoutKind.Sequential)]
  252. public class BITMAPINFOHEADER 
  253. {
  254. public int      biSize = Marshal.SizeOf(typeof(BITMAPINFOHEADER));
  255. public int      biWidth;
  256. public int      biHeight;
  257. public short    biPlanes;
  258. public short    biBitCount;
  259. public int      biCompression;
  260. public int      biSizeImage;
  261. public int      biXPelsPerMeter;
  262. public int      biYPelsPerMeter;
  263. public int      biClrUsed;
  264. public int      biClrImportant;
  265. }
  266. #endregion
  267. #region BITMAPINFO
  268. [StructLayout(LayoutKind.Sequential)]
  269. public class BITMAPINFO 
  270. {
  271. public BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
  272. [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=1024)]
  273. public byte[] bmiColors; 
  274. }
  275. #endregion
  276. #region PALETTEENTRY
  277. [StructLayout(LayoutKind.Sequential)]
  278. public struct PALETTEENTRY 
  279. {
  280. public byte peRed;
  281. public byte peGreen;
  282. public byte peBlue;
  283. public byte peFlags;
  284. }
  285. #endregion
  286. #region MSG
  287. [StructLayout(LayoutKind.Sequential)]
  288. public struct MSG 
  289. {
  290. public IntPtr hwnd;
  291. public int message;
  292. public IntPtr wParam;
  293. public IntPtr lParam;
  294. public int time;
  295. public int pt_x;
  296. public int pt_y;
  297. }
  298. #endregion
  299. #region HD_HITTESTINFO
  300. [StructLayout(LayoutKind.Sequential)]
  301. public struct HD_HITTESTINFO 
  302. {  
  303. public POINT pt;  
  304. public HeaderControlHitTestFlags flags; 
  305. public int iItem; 
  306. }
  307. #endregion
  308.  
  309. #region DLLVERSIONINFO
  310. [StructLayout(LayoutKind.Sequential)]
  311. public struct DLLVERSIONINFO
  312. {
  313. public int cbSize;
  314. public int dwMajorVersion;
  315. public int dwMinorVersion;
  316. public int dwBuildNumber;
  317. public int dwPlatformID;
  318. }
  319. #endregion
  320. #region PAINTSTRUCT
  321. [StructLayout(LayoutKind.Sequential)]
  322. public struct PAINTSTRUCT
  323. {
  324. public IntPtr hdc;
  325. public int fErase;
  326. public Rectangle rcPaint;
  327. public int fRestore;
  328. public int fIncUpdate;
  329. public int Reserved1;
  330. public int Reserved2;
  331. public int Reserved3;
  332. public int Reserved4;
  333. public int Reserved5;
  334. public int Reserved6;
  335. public int Reserved7;
  336. public int Reserved8;
  337. }
  338. #endregion
  339. #region BLENDFUNCTION
  340. [StructLayout(LayoutKind.Sequential, Pack=1)]
  341. public struct BLENDFUNCTION
  342. {
  343. public byte BlendOp;
  344. public byte BlendFlags;
  345. public byte SourceConstantAlpha;
  346. public byte AlphaFormat;
  347. }
  348. #endregion
  349. #region TRACKMOUSEEVENTS
  350. [StructLayout(LayoutKind.Sequential)]
  351. public struct TRACKMOUSEEVENTS
  352. {
  353. public uint cbSize;
  354. public TrackerEventFlags dwFlags;
  355. public IntPtr hWnd;
  356. public uint dwHoverTime;
  357. }
  358. #endregion
  359. #region NMTVCUSTOMDRAW
  360. [StructLayout(LayoutKind.Sequential)]
  361. public struct NMTVCUSTOMDRAW 
  362. {
  363. public NMCUSTOMDRAW nmcd;
  364. public uint clrText;
  365. public uint clrTextBk;
  366. public int iLevel;
  367. }
  368. #endregion
  369. #region TVITEM
  370. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
  371. public struct TVITEM 
  372. {
  373. public uint      mask;
  374. public IntPtr    hItem;
  375. public uint      state;
  376. public uint      stateMask;
  377. public IntPtr    pszText;
  378. public int       cchTextMax;
  379. public int       iImage;
  380. public int       iSelectedImage;
  381. public int       cChildren;
  382. public IntPtr    lParam;
  383. #endregion
  384. #region LVITEM
  385. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
  386. public struct LVITEM
  387. {
  388. public ListViewItemFlags mask;
  389. public int iItem;
  390. public int iSubItem;
  391. public uint state;
  392. public uint stateMask;
  393. public IntPtr pszText;
  394. public int cchTextMax;
  395. public int iImage;
  396. public int lParam;
  397. public int iIndent;
  398. }
  399. #endregion
  400. #region HDITEM
  401. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
  402. public struct HDITEM
  403. {
  404. public HeaderItemFlags mask;
  405. public int     cxy;
  406. public IntPtr  pszText;
  407. public IntPtr  hbm;
  408. public int     cchTextMax;
  409. public int     fmt;
  410. public int     lParam;
  411. public int     iImage;      
  412. public int     iOrder;
  413. }
  414. #endregion
  415.     #region WINDOWPLACEMENT
  416. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
  417. public struct WINDOWPLACEMENT
  418. {
  419. public uint length; 
  420. public uint flags; 
  421. public uint showCmd; 
  422. public POINT ptMinPosition; 
  423. public POINT ptMaxPosition; 
  424. public RECT  rcNormalPosition; 
  425. }
  426. #endregion
  427. #region SCROLLINFO
  428. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
  429. public struct SCROLLINFO
  430. {
  431. public  uint   cbSize;
  432. public  uint   fMask;
  433. public  int    nMin;
  434. public  int    nMax;
  435. public  uint   nPage;
  436. public  int    nPos;
  437. public  int    nTrackPos;
  438. }
  439. #endregion
  440. #region SHFILEINFO
  441. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
  442. public struct SHFILEINFO
  443. public IntPtr hIcon; 
  444. public int    iIcon; 
  445. public uint   dwAttributes; 
  446. [MarshalAs(UnmanagedType.ByValTStr, SizeConst=260)]
  447. public string szDisplayName; 
  448. [MarshalAs(UnmanagedType.ByValTStr, SizeConst=80)]
  449. public string szTypeName; 
  450. }
  451. #endregion
  452. #region SHITEMID
  453. [StructLayout(LayoutKind.Sequential)]
  454. public struct SHITEMID 
  455. public ushort cb; 
  456. [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=1)]
  457. public byte[]  abID; 
  458. }
  459. #endregion
  460. #region ITEMIDLIST
  461. [StructLayout(LayoutKind.Sequential)]
  462. public struct ITEMIDLIST 
  463. {
  464. public SHITEMID mkid;
  465. }
  466. #endregion
  467.  
  468. #region IID
  469. [StructLayout(LayoutKind.Sequential)]
  470. public struct IID
  471. {
  472. uint x;
  473. short s1;
  474. short s2;
  475. [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=8)]
  476. byte[] chars; 
  477. }
  478. #endregion
  479. #region REFIID
  480. [StructLayout(LayoutKind.Sequential)]
  481. public struct REFIID
  482. {
  483. public uint x;
  484. public short s1;
  485. public short s2;
  486. [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=8)]
  487. public byte[] chars; 
  488. public REFIID(string guid)
  489. {
  490. // Needs to be a string of the form:
  491. // "000214E6-0000-0000-c000-000000000046"
  492. string[] data = guid.Split('-');
  493. Debug.Assert(data.Length == 5);
  494.             x = Convert.ToUInt32(data[0], 16);
  495. s1 = Convert.ToInt16(data[1], 16);
  496. s2 = Convert.ToInt16(data[2], 16);
  497. string bytesData = data[3] + data[4];
  498. chars = new byte[] { Convert.ToByte(bytesData.Substring(0,2), 16),  Convert.ToByte(bytesData.Substring(2,2), 16), 
  499.  Convert.ToByte(bytesData.Substring(4,2), 16),  Convert.ToByte(bytesData.Substring(6,2), 16),
  500.  Convert.ToByte(bytesData.Substring(8,2), 16),  Convert.ToByte(bytesData.Substring(10,2), 16), 
  501.  Convert.ToByte(bytesData.Substring(12,2), 16),  Convert.ToByte(bytesData.Substring(14,2), 16) }; 
  502. }
  503. }
  504. #endregion
  505. #region STRRET
  506. [StructLayout(LayoutKind.Explicit, CharSet=CharSet.Auto)]
  507. public struct STRRET
  508. {
  509. [FieldOffset(0)]public STRRETFlags     uType;         // One of the STRRET values
  510. [FieldOffset(4)]public IntPtr          pOleStr;       // must be freed by caller of GetDisplayNameOf
  511. [FieldOffset(4)]public IntPtr          pStr;          // NOT USED
  512. [FieldOffset(4)]public uint            uOffset;       // Offset into SHITEMID
  513. [FieldOffset(4)]public IntPtr         cStr;          // Buffer to fill in (ANSI)
  514. }
  515. #endregion
  516. #region TVINSERTSTRUCT
  517. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
  518. public struct TVINSERTSTRUCT
  519. {
  520. public uint hParent;
  521. public uint hInsertAfter;
  522. public TVITEM   item;
  523.     }
  524. #endregion
  525. #region NM_TREEVIEW
  526. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
  527. public struct NM_TREEVIEW
  528. {
  529. public NMHDR     hdr;
  530. public uint      action;
  531. public TVITEM    itemOld;
  532. public TVITEM    itemNew;
  533. public POINT     ptDrag;
  534. }
  535. #endregion
  536. #region TVHITTESTINFO
  537. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
  538. public struct TVHITTESTINFO
  539. {
  540. public POINT  pt;
  541. public TreeViewHitTestFlags  flags;
  542. public IntPtr hItem;
  543. }
  544. #endregion
  545. #region TVSORTCB
  546. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
  547. public struct TVSORTCB
  548. {
  549. public IntPtr hParent;
  550. public WindowsAPI.CompareFunc lpfnCompare;
  551. public int lParam;
  552. }
  553. #endregion
  554. #region SCROLLBARINFO
  555. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
  556. public struct SCROLLBARINFO
  557. {
  558. public uint  cbSize;
  559. public RECT  rcScrollBar;
  560. public int   dxyLineButton;
  561. public int   xyThumbTop;
  562. public int   xyThumbBottom;
  563. public int   reserved;
  564. [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst=6)]
  565. public uint[] rgstate;
  566. }
  567. #endregion
  568. #region CMINVOKECOMMANDINFO
  569. [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
  570. public struct CMINVOKECOMMANDINFO
  571. {
  572. public uint cbSize; // sizeof(CMINVOKECOMMANDINFO)
  573. public uint fMask; // any combination of CMIC_MASK_*
  574. public IntPtr hwnd; // might be NULL (indicating no owner window)
  575. public IntPtr lpVerb; // either a string or MAKEINTRESOURCE(idOffset)
  576. public IntPtr lpParameters; // might be NULL (indicating no parameter)
  577. public IntPtr lpDirectory; // might be NULL (indicating no specific directory)
  578. public int nShow; // one of SW_ values for ShowWindow() API
  579. public uint dwHotKey;
  580. public IntPtr hIcon;
  581. }
  582. #endregion
  583. }