WinApi.cs 2.6 KB

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