WinApi.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace ControlCatalog.NetCore;
  4. internal unsafe class WinApi
  5. {
  6. public enum CommonControls : uint
  7. {
  8. ICC_LISTVIEW_CLASSES = 0x00000001, // listview, header
  9. ICC_TREEVIEW_CLASSES = 0x00000002, // treeview, tooltips
  10. ICC_BAR_CLASSES = 0x00000004, // toolbar, statusbar, trackbar, tooltips
  11. ICC_TAB_CLASSES = 0x00000008, // tab, tooltips
  12. ICC_UPDOWN_CLASS = 0x00000010, // updown
  13. ICC_PROGRESS_CLASS = 0x00000020, // progress
  14. ICC_HOTKEY_CLASS = 0x00000040, // hotkey
  15. ICC_ANIMATE_CLASS = 0x00000080, // animate
  16. ICC_WIN95_CLASSES = 0x000000FF,
  17. ICC_DATE_CLASSES = 0x00000100, // month picker, date picker, time picker, updown
  18. ICC_USEREX_CLASSES = 0x00000200, // comboex
  19. ICC_COOL_CLASSES = 0x00000400, // rebar (coolbar) control
  20. ICC_INTERNET_CLASSES = 0x00000800,
  21. ICC_PAGESCROLLER_CLASS = 0x00001000, // page scroller
  22. ICC_NATIVEFNTCTL_CLASS = 0x00002000, // native font control
  23. ICC_STANDARD_CLASSES = 0x00004000,
  24. ICC_LINK_CLASS = 0x00008000
  25. }
  26. [StructLayout(LayoutKind.Sequential)]
  27. public struct INITCOMMONCONTROLSEX
  28. {
  29. public int dwSize;
  30. public uint dwICC;
  31. }
  32. [DllImport("Comctl32.dll")]
  33. public static extern void InitCommonControlsEx(ref INITCOMMONCONTROLSEX init);
  34. [DllImport("user32.dll", SetLastError = true)]
  35. public static extern bool DestroyWindow(IntPtr hwnd);
  36. [DllImport("kernel32.dll")]
  37. public static extern IntPtr LoadLibrary(string lib);
  38. [DllImport("kernel32.dll")]
  39. public static extern IntPtr GetModuleHandle(string lpModuleName);
  40. [DllImport("user32.dll", SetLastError = true)]
  41. public static extern IntPtr CreateWindowEx(
  42. int dwExStyle,
  43. string lpClassName,
  44. string lpWindowName,
  45. uint dwStyle,
  46. int x,
  47. int y,
  48. int nWidth,
  49. int nHeight,
  50. IntPtr hWndParent,
  51. IntPtr hMenu,
  52. IntPtr hInstance,
  53. IntPtr lpParam);
  54. [StructLayout(LayoutKind.Sequential)]
  55. public struct SETTEXTEX
  56. {
  57. public uint Flags;
  58. public uint Codepage;
  59. }
  60. [DllImport("user32.dll", CharSet = CharSet.Unicode, EntryPoint = "SendMessageW")]
  61. public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, ref SETTEXTEX wParam, byte[] lParam);
  62. }