UnmanagedMethods.cs 84 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419
  1. using System;
  2. using System.ComponentModel;
  3. using System.Diagnostics.CodeAnalysis;
  4. using System.Runtime.CompilerServices;
  5. using System.Runtime.InteropServices;
  6. using System.Runtime.InteropServices.ComTypes;
  7. using System.Text;
  8. using Avalonia.MicroCom;
  9. using Avalonia.Win32.Win32Com;
  10. // ReSharper disable InconsistentNaming
  11. #pragma warning disable 169, 649
  12. namespace Avalonia.Win32.Interop
  13. {
  14. [SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1305:FieldNamesMustNotUseHungarianNotation", Justification = "Using Win32 naming for consistency.")]
  15. [SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter", Justification = "Using Win32 naming for consistency.")]
  16. [SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1310:FieldNamesMustNotContainUnderscore", Justification = "Using Win32 naming for consistency.")]
  17. [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements must be documented", Justification = "Look in Win32 docs.")]
  18. [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:Enumeration items must be documented", Justification = "Look in Win32 docs.")]
  19. internal unsafe static class UnmanagedMethods
  20. {
  21. public const int CW_USEDEFAULT = unchecked((int)0x80000000);
  22. public delegate void TimerProc(IntPtr hWnd, uint uMsg, IntPtr nIDEvent, uint dwTime);
  23. public delegate void TimeCallback(uint uTimerID, uint uMsg, UIntPtr dwUser, UIntPtr dw1, UIntPtr dw2);
  24. [UnmanagedFunctionPointer(CallingConvention.StdCall)]
  25. public delegate void WaitOrTimerCallback(IntPtr lpParameter, bool timerOrWaitFired);
  26. public delegate IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
  27. public static readonly IntPtr DPI_AWARENESS_CONTEXT_UNAWARE = new IntPtr(-1);
  28. public static readonly IntPtr DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = new IntPtr(-2);
  29. public static readonly IntPtr DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = new IntPtr(-3);
  30. public static readonly IntPtr DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = new IntPtr(-4);
  31. public enum Cursor
  32. {
  33. IDC_ARROW = 32512,
  34. IDC_IBEAM = 32513,
  35. IDC_WAIT = 32514,
  36. IDC_CROSS = 32515,
  37. IDC_UPARROW = 32516,
  38. IDC_SIZE = 32640,
  39. IDC_ICON = 32641,
  40. IDC_SIZENWSE = 32642,
  41. IDC_SIZENESW = 32643,
  42. IDC_SIZEWE = 32644,
  43. IDC_SIZENS = 32645,
  44. IDC_SIZEALL = 32646,
  45. IDC_NO = 32648,
  46. IDC_HAND = 32649,
  47. IDC_APPSTARTING = 32650,
  48. IDC_HELP = 32651
  49. }
  50. public enum MouseActivate : int
  51. {
  52. MA_ACTIVATE = 1,
  53. MA_ACTIVATEANDEAT = 2,
  54. MA_NOACTIVATE = 3,
  55. MA_NOACTIVATEANDEAT = 4
  56. }
  57. [Flags]
  58. public enum SetWindowPosFlags : uint
  59. {
  60. SWP_ASYNCWINDOWPOS = 0x4000,
  61. SWP_DEFERERASE = 0x2000,
  62. SWP_DRAWFRAME = 0x0020,
  63. SWP_FRAMECHANGED = 0x0020,
  64. SWP_HIDEWINDOW = 0x0080,
  65. SWP_NOACTIVATE = 0x0010,
  66. SWP_NOCOPYBITS = 0x0100,
  67. SWP_NOMOVE = 0x0002,
  68. SWP_NOOWNERZORDER = 0x0200,
  69. SWP_NOREDRAW = 0x0008,
  70. SWP_NOREPOSITION = 0x0200,
  71. SWP_NOSENDCHANGING = 0x0400,
  72. SWP_NOSIZE = 0x0001,
  73. SWP_NOZORDER = 0x0004,
  74. SWP_SHOWWINDOW = 0x0040,
  75. SWP_RESIZE = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER
  76. }
  77. public static class WindowPosZOrder
  78. {
  79. public static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
  80. public static readonly IntPtr HWND_TOP = new IntPtr(0);
  81. public static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
  82. public static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
  83. }
  84. public enum SizeCommand
  85. {
  86. Restored,
  87. Minimized,
  88. Maximized,
  89. MaxShow,
  90. MaxHide,
  91. }
  92. public enum ShowWindowCommand
  93. {
  94. Hide = 0,
  95. Normal = 1,
  96. ShowMinimized = 2,
  97. Maximize = 3,
  98. ShowMaximized = 3,
  99. ShowNoActivate = 4,
  100. Show = 5,
  101. Minimize = 6,
  102. ShowMinNoActive = 7,
  103. ShowNA = 8,
  104. Restore = 9,
  105. ShowDefault = 10,
  106. ForceMinimize = 11
  107. }
  108. public enum SystemMetric
  109. {
  110. SM_CXSCREEN = 0, // 0x00
  111. SM_CYSCREEN = 1, // 0x01
  112. SM_CXVSCROLL = 2, // 0x02
  113. SM_CYHSCROLL = 3, // 0x03
  114. SM_CYCAPTION = 4, // 0x04
  115. SM_CXBORDER = 5, // 0x05
  116. SM_CYBORDER = 6, // 0x06
  117. SM_CXDLGFRAME = 7, // 0x07
  118. SM_CXFIXEDFRAME = 7, // 0x07
  119. SM_CYDLGFRAME = 8, // 0x08
  120. SM_CYFIXEDFRAME = 8, // 0x08
  121. SM_CYVTHUMB = 9, // 0x09
  122. SM_CXHTHUMB = 10, // 0x0A
  123. SM_CXICON = 11, // 0x0B
  124. SM_CYICON = 12, // 0x0C
  125. SM_CXCURSOR = 13, // 0x0D
  126. SM_CYCURSOR = 14, // 0x0E
  127. SM_CYMENU = 15, // 0x0F
  128. SM_CXFULLSCREEN = 16, // 0x10
  129. SM_CYFULLSCREEN = 17, // 0x11
  130. SM_CYKANJIWINDOW = 18, // 0x12
  131. SM_MOUSEPRESENT = 19, // 0x13
  132. SM_CYVSCROLL = 20, // 0x14
  133. SM_CXHSCROLL = 21, // 0x15
  134. SM_DEBUG = 22, // 0x16
  135. SM_SWAPBUTTON = 23, // 0x17
  136. SM_CXMIN = 28, // 0x1C
  137. SM_CYMIN = 29, // 0x1D
  138. SM_CXSIZE = 30, // 0x1E
  139. SM_CYSIZE = 31, // 0x1F
  140. SM_CXSIZEFRAME = 32, // 0x20
  141. SM_CXFRAME = 32, // 0x20
  142. SM_CYSIZEFRAME = 33, // 0x21
  143. SM_CYFRAME = 33, // 0x21
  144. SM_CXMINTRACK = 34, // 0x22
  145. SM_CYMINTRACK = 35, // 0x23
  146. SM_CXDOUBLECLK = 36, // 0x24
  147. SM_CYDOUBLECLK = 37, // 0x25
  148. SM_CXICONSPACING = 38, // 0x26
  149. SM_CYICONSPACING = 39, // 0x27
  150. SM_MENUDROPALIGNMENT = 40, // 0x28
  151. SM_PENWINDOWS = 41, // 0x29
  152. SM_DBCSENABLED = 42, // 0x2A
  153. SM_CMOUSEBUTTONS = 43, // 0x2B
  154. SM_SECURE = 44, // 0x2C
  155. SM_CXEDGE = 45, // 0x2D
  156. SM_CYEDGE = 46, // 0x2E
  157. SM_CXMINSPACING = 47, // 0x2F
  158. SM_CYMINSPACING = 48, // 0x30
  159. SM_CXSMICON = 49, // 0x31
  160. SM_CYSMICON = 50, // 0x32
  161. SM_CYSMCAPTION = 51, // 0x33
  162. SM_CXSMSIZE = 52, // 0x34
  163. SM_CYSMSIZE = 53, // 0x35
  164. SM_CXMENUSIZE = 54, // 0x36
  165. SM_CYMENUSIZE = 55, // 0x37
  166. SM_ARRANGE = 56, // 0x38
  167. SM_CXMINIMIZED = 57, // 0x39
  168. SM_CYMINIMIZED = 58, // 0x3A
  169. SM_CXMAXTRACK = 59, // 0x3B
  170. SM_CYMAXTRACK = 60, // 0x3C
  171. SM_CXMAXIMIZED = 61, // 0x3D
  172. SM_CYMAXIMIZED = 62, // 0x3E
  173. SM_NETWORK = 63, // 0x3F
  174. SM_CLEANBOOT = 67, // 0x43
  175. SM_CXDRAG = 68, // 0x44
  176. SM_CYDRAG = 69, // 0x45
  177. SM_SHOWSOUNDS = 70, // 0x46
  178. SM_CXMENUCHECK = 71, // 0x47
  179. SM_CYMENUCHECK = 72, // 0x48
  180. SM_SLOWMACHINE = 73, // 0x49
  181. SM_MIDEASTENABLED = 74, // 0x4A
  182. SM_MOUSEWHEELPRESENT = 75, // 0x4B
  183. SM_XVIRTUALSCREEN = 76, // 0x4C
  184. SM_YVIRTUALSCREEN = 77, // 0x4D
  185. SM_CXVIRTUALSCREEN = 78, // 0x4E
  186. SM_CYVIRTUALSCREEN = 79, // 0x4F
  187. SM_CMONITORS = 80, // 0x50
  188. SM_SAMEDISPLAYFORMAT = 81, // 0x51
  189. SM_IMMENABLED = 82, // 0x52
  190. SM_CXFOCUSBORDER = 83, // 0x53
  191. SM_CYFOCUSBORDER = 84, // 0x54
  192. SM_TABLETPC = 86, // 0x56
  193. SM_MEDIACENTER = 87, // 0x57
  194. SM_STARTER = 88, // 0x58
  195. SM_SERVERR2 = 89, // 0x59
  196. SM_MOUSEHORIZONTALWHEELPRESENT = 91, // 0x5B
  197. SM_CXPADDEDBORDER = 92, // 0x5C
  198. SM_DIGITIZER = 94, // 0x5E
  199. SM_MAXIMUMTOUCHES = 95, // 0x5F
  200. SM_REMOTESESSION = 0x1000, // 0x1000
  201. SM_SHUTTINGDOWN = 0x2000, // 0x2000
  202. SM_REMOTECONTROL = 0x2001, // 0x2001
  203. SM_CONVERTABLESLATEMODE = 0x2003,
  204. SM_SYSTEMDOCKED = 0x2004,
  205. }
  206. [Flags]
  207. public enum ModifierKeys
  208. {
  209. MK_NONE = 0x0000,
  210. MK_LBUTTON = 0x0001,
  211. MK_RBUTTON = 0x0002,
  212. MK_SHIFT = 0x0004,
  213. MK_CONTROL = 0x0008,
  214. MK_MBUTTON = 0x0010,
  215. MK_ALT = 0x0020,
  216. MK_XBUTTON1 = 0x0020,
  217. MK_XBUTTON2 = 0x0040
  218. }
  219. public enum VirtualKeyStates : int
  220. {
  221. VK_LBUTTON = 0x01,
  222. VK_RBUTTON = 0x02,
  223. VK_CANCEL = 0x03,
  224. VK_MBUTTON = 0x04,
  225. VK_XBUTTON1 = 0x05,
  226. VK_XBUTTON2 = 0x06,
  227. VK_BACK = 0x08,
  228. VK_TAB = 0x09,
  229. VK_CLEAR = 0x0C,
  230. VK_RETURN = 0x0D,
  231. VK_SHIFT = 0x10,
  232. VK_CONTROL = 0x11,
  233. VK_MENU = 0x12,
  234. VK_PAUSE = 0x13,
  235. VK_CAPITAL = 0x14,
  236. VK_KANA = 0x15,
  237. VK_HANGEUL = 0x15,
  238. VK_HANGUL = 0x15,
  239. VK_JUNJA = 0x17,
  240. VK_FINAL = 0x18,
  241. VK_HANJA = 0x19,
  242. VK_KANJI = 0x19,
  243. VK_ESCAPE = 0x1B,
  244. VK_CONVERT = 0x1C,
  245. VK_NONCONVERT = 0x1D,
  246. VK_ACCEPT = 0x1E,
  247. VK_MODECHANGE = 0x1F,
  248. VK_SPACE = 0x20,
  249. VK_PRIOR = 0x21,
  250. VK_NEXT = 0x22,
  251. VK_END = 0x23,
  252. VK_HOME = 0x24,
  253. VK_LEFT = 0x25,
  254. VK_UP = 0x26,
  255. VK_RIGHT = 0x27,
  256. VK_DOWN = 0x28,
  257. VK_SELECT = 0x29,
  258. VK_PRINT = 0x2A,
  259. VK_EXECUTE = 0x2B,
  260. VK_SNAPSHOT = 0x2C,
  261. VK_INSERT = 0x2D,
  262. VK_DELETE = 0x2E,
  263. VK_HELP = 0x2F,
  264. VK_LWIN = 0x5B,
  265. VK_RWIN = 0x5C,
  266. VK_APPS = 0x5D,
  267. VK_SLEEP = 0x5F,
  268. VK_NUMPAD0 = 0x60,
  269. VK_NUMPAD1 = 0x61,
  270. VK_NUMPAD2 = 0x62,
  271. VK_NUMPAD3 = 0x63,
  272. VK_NUMPAD4 = 0x64,
  273. VK_NUMPAD5 = 0x65,
  274. VK_NUMPAD6 = 0x66,
  275. VK_NUMPAD7 = 0x67,
  276. VK_NUMPAD8 = 0x68,
  277. VK_NUMPAD9 = 0x69,
  278. VK_MULTIPLY = 0x6A,
  279. VK_ADD = 0x6B,
  280. VK_SEPARATOR = 0x6C,
  281. VK_SUBTRACT = 0x6D,
  282. VK_DECIMAL = 0x6E,
  283. VK_DIVIDE = 0x6F,
  284. VK_F1 = 0x70,
  285. VK_F2 = 0x71,
  286. VK_F3 = 0x72,
  287. VK_F4 = 0x73,
  288. VK_F5 = 0x74,
  289. VK_F6 = 0x75,
  290. VK_F7 = 0x76,
  291. VK_F8 = 0x77,
  292. VK_F9 = 0x78,
  293. VK_F10 = 0x79,
  294. VK_F11 = 0x7A,
  295. VK_F12 = 0x7B,
  296. VK_F13 = 0x7C,
  297. VK_F14 = 0x7D,
  298. VK_F15 = 0x7E,
  299. VK_F16 = 0x7F,
  300. VK_F17 = 0x80,
  301. VK_F18 = 0x81,
  302. VK_F19 = 0x82,
  303. VK_F20 = 0x83,
  304. VK_F21 = 0x84,
  305. VK_F22 = 0x85,
  306. VK_F23 = 0x86,
  307. VK_F24 = 0x87,
  308. VK_NUMLOCK = 0x90,
  309. VK_SCROLL = 0x91,
  310. VK_OEM_NEC_EQUAL = 0x92,
  311. VK_OEM_FJ_JISHO = 0x92,
  312. VK_OEM_FJ_MASSHOU = 0x93,
  313. VK_OEM_FJ_TOUROKU = 0x94,
  314. VK_OEM_FJ_LOYA = 0x95,
  315. VK_OEM_FJ_ROYA = 0x96,
  316. VK_LSHIFT = 0xA0,
  317. VK_RSHIFT = 0xA1,
  318. VK_LCONTROL = 0xA2,
  319. VK_RCONTROL = 0xA3,
  320. VK_LMENU = 0xA4,
  321. VK_RMENU = 0xA5,
  322. VK_BROWSER_BACK = 0xA6,
  323. VK_BROWSER_FORWARD = 0xA7,
  324. VK_BROWSER_REFRESH = 0xA8,
  325. VK_BROWSER_STOP = 0xA9,
  326. VK_BROWSER_SEARCH = 0xAA,
  327. VK_BROWSER_FAVORITES = 0xAB,
  328. VK_BROWSER_HOME = 0xAC,
  329. VK_VOLUME_MUTE = 0xAD,
  330. VK_VOLUME_DOWN = 0xAE,
  331. VK_VOLUME_UP = 0xAF,
  332. VK_MEDIA_NEXT_TRACK = 0xB0,
  333. VK_MEDIA_PREV_TRACK = 0xB1,
  334. VK_MEDIA_STOP = 0xB2,
  335. VK_MEDIA_PLAY_PAUSE = 0xB3,
  336. VK_LAUNCH_MAIL = 0xB4,
  337. VK_LAUNCH_MEDIA_SELECT = 0xB5,
  338. VK_LAUNCH_APP1 = 0xB6,
  339. VK_LAUNCH_APP2 = 0xB7,
  340. VK_OEM_1 = 0xBA,
  341. VK_OEM_PLUS = 0xBB,
  342. VK_OEM_COMMA = 0xBC,
  343. VK_OEM_MINUS = 0xBD,
  344. VK_OEM_PERIOD = 0xBE,
  345. VK_OEM_2 = 0xBF,
  346. VK_OEM_3 = 0xC0,
  347. VK_OEM_4 = 0xDB,
  348. VK_OEM_5 = 0xDC,
  349. VK_OEM_6 = 0xDD,
  350. VK_OEM_7 = 0xDE,
  351. VK_OEM_8 = 0xDF,
  352. VK_OEM_AX = 0xE1,
  353. VK_OEM_102 = 0xE2,
  354. VK_ICO_HELP = 0xE3,
  355. VK_ICO_00 = 0xE4,
  356. VK_PROCESSKEY = 0xE5,
  357. VK_ICO_CLEAR = 0xE6,
  358. VK_PACKET = 0xE7,
  359. VK_OEM_RESET = 0xE9,
  360. VK_OEM_JUMP = 0xEA,
  361. VK_OEM_PA1 = 0xEB,
  362. VK_OEM_PA2 = 0xEC,
  363. VK_OEM_PA3 = 0xED,
  364. VK_OEM_WSCTRL = 0xEE,
  365. VK_OEM_CUSEL = 0xEF,
  366. VK_OEM_ATTN = 0xF0,
  367. VK_OEM_FINISH = 0xF1,
  368. VK_OEM_COPY = 0xF2,
  369. VK_OEM_AUTO = 0xF3,
  370. VK_OEM_ENLW = 0xF4,
  371. VK_OEM_BACKTAB = 0xF5,
  372. VK_ATTN = 0xF6,
  373. VK_CRSEL = 0xF7,
  374. VK_EXSEL = 0xF8,
  375. VK_EREOF = 0xF9,
  376. VK_PLAY = 0xFA,
  377. VK_ZOOM = 0xFB,
  378. VK_NONAME = 0xFC,
  379. VK_PA1 = 0xFD,
  380. VK_OEM_CLEAR = 0xFE
  381. }
  382. public enum WindowActivate
  383. {
  384. WA_INACTIVE,
  385. WA_ACTIVE,
  386. WA_CLICKACTIVE,
  387. }
  388. public enum HitTestValues
  389. {
  390. HTERROR = -2,
  391. HTTRANSPARENT = -1,
  392. HTNOWHERE = 0,
  393. HTCLIENT = 1,
  394. HTCAPTION = 2,
  395. HTSYSMENU = 3,
  396. HTGROWBOX = 4,
  397. HTMENU = 5,
  398. HTHSCROLL = 6,
  399. HTVSCROLL = 7,
  400. HTMINBUTTON = 8,
  401. HTMAXBUTTON = 9,
  402. HTLEFT = 10,
  403. HTRIGHT = 11,
  404. HTTOP = 12,
  405. HTTOPLEFT = 13,
  406. HTTOPRIGHT = 14,
  407. HTBOTTOM = 15,
  408. HTBOTTOMLEFT = 16,
  409. HTBOTTOMRIGHT = 17,
  410. HTBORDER = 18,
  411. HTOBJECT = 19,
  412. HTCLOSE = 20,
  413. HTHELP = 21
  414. }
  415. [Flags]
  416. public enum WindowStyles : uint
  417. {
  418. WS_BORDER = 0x800000,
  419. WS_CAPTION = 0xc00000,
  420. WS_CHILD = 0x40000000,
  421. WS_CLIPCHILDREN = 0x2000000,
  422. WS_CLIPSIBLINGS = 0x4000000,
  423. WS_DISABLED = 0x8000000,
  424. WS_DLGFRAME = 0x400000,
  425. WS_GROUP = 0x20000,
  426. WS_HSCROLL = 0x100000,
  427. WS_MAXIMIZE = 0x1000000,
  428. WS_MAXIMIZEBOX = 0x10000,
  429. WS_MINIMIZE = 0x20000000,
  430. WS_MINIMIZEBOX = 0x20000,
  431. WS_OVERLAPPED = 0x0,
  432. WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_SIZEFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
  433. WS_POPUP = 0x80000000u,
  434. WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU,
  435. WS_SIZEFRAME = 0x40000,
  436. WS_SYSMENU = 0x80000,
  437. WS_TABSTOP = 0x10000,
  438. WS_THICKFRAME = 0x40000,
  439. WS_VISIBLE = 0x10000000,
  440. WS_VSCROLL = 0x200000,
  441. WS_EX_DLGMODALFRAME = 0x00000001,
  442. WS_EX_NOPARENTNOTIFY = 0x00000004,
  443. WS_EX_NOREDIRECTIONBITMAP = 0x00200000,
  444. WS_EX_TOPMOST = 0x00000008,
  445. WS_EX_ACCEPTFILES = 0x00000010,
  446. WS_EX_TRANSPARENT = 0x00000020,
  447. WS_EX_MDICHILD = 0x00000040,
  448. WS_EX_TOOLWINDOW = 0x00000080,
  449. WS_EX_WINDOWEDGE = 0x00000100,
  450. WS_EX_CLIENTEDGE = 0x00000200,
  451. WS_EX_CONTEXTHELP = 0x00000400,
  452. WS_EX_RIGHT = 0x00001000,
  453. WS_EX_LEFT = 0x00000000,
  454. WS_EX_RTLREADING = 0x00002000,
  455. WS_EX_LTRREADING = 0x00000000,
  456. WS_EX_LEFTSCROLLBAR = 0x00004000,
  457. WS_EX_RIGHTSCROLLBAR = 0x00000000,
  458. WS_EX_CONTROLPARENT = 0x00010000,
  459. WS_EX_STATICEDGE = 0x00020000,
  460. WS_EX_APPWINDOW = 0x00040000,
  461. WS_EX_OVERLAPPEDWINDOW = WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
  462. WS_EX_PALETTEWINDOW = WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST,
  463. WS_EX_LAYERED = 0x00080000,
  464. WS_EX_NOINHERITLAYOUT = 0x00100000,
  465. WS_EX_LAYOUTRTL = 0x00400000,
  466. WS_EX_COMPOSITED = 0x02000000,
  467. WS_EX_NOACTIVATE = 0x08000000
  468. }
  469. [Flags]
  470. public enum ClassStyles : uint
  471. {
  472. CS_VREDRAW = 0x0001,
  473. CS_HREDRAW = 0x0002,
  474. CS_DBLCLKS = 0x0008,
  475. CS_OWNDC = 0x0020,
  476. CS_CLASSDC = 0x0040,
  477. CS_PARENTDC = 0x0080,
  478. CS_NOCLOSE = 0x0200,
  479. CS_SAVEBITS = 0x0800,
  480. CS_BYTEALIGNCLIENT = 0x1000,
  481. CS_BYTEALIGNWINDOW = 0x2000,
  482. CS_GLOBALCLASS = 0x4000,
  483. CS_IME = 0x00010000,
  484. CS_DROPSHADOW = 0x00020000
  485. }
  486. [Flags]
  487. public enum PointerDeviceChangeFlags
  488. {
  489. PDC_ARRIVAL = 0x001,
  490. PDC_REMOVAL = 0x002,
  491. PDC_ORIENTATION_0 = 0x004,
  492. PDC_ORIENTATION_90 = 0x008,
  493. PDC_ORIENTATION_180 = 0x010,
  494. PDC_ORIENTATION_270 = 0x020,
  495. PDC_MODE_DEFAULT = 0x040,
  496. PDC_MODE_CENTERED = 0x080,
  497. PDC_MAPPING_CHANGE = 0x100,
  498. PDC_RESOLUTION = 0x200,
  499. PDC_ORIGIN = 0x400,
  500. PDC_MODE_ASPECTRATIOPRESERVED = 0x800
  501. }
  502. public enum PointerInputType
  503. {
  504. PT_NONE = 0x00000000,
  505. PT_POINTER = 0x00000001,
  506. PT_TOUCH = 0x00000002,
  507. PT_PEN = 0x00000003,
  508. PT_MOUSE = 0x00000004,
  509. PT_TOUCHPAD = 0x00000005
  510. }
  511. public enum WindowsMessage : uint
  512. {
  513. WM_NULL = 0x0000,
  514. WM_CREATE = 0x0001,
  515. WM_DESTROY = 0x0002,
  516. WM_MOVE = 0x0003,
  517. WM_SIZE = 0x0005,
  518. WM_ACTIVATE = 0x0006,
  519. WM_SETFOCUS = 0x0007,
  520. WM_KILLFOCUS = 0x0008,
  521. WM_ENABLE = 0x000A,
  522. WM_SETREDRAW = 0x000B,
  523. WM_SETTEXT = 0x000C,
  524. WM_GETTEXT = 0x000D,
  525. WM_GETTEXTLENGTH = 0x000E,
  526. WM_PAINT = 0x000F,
  527. WM_CLOSE = 0x0010,
  528. WM_QUERYENDSESSION = 0x0011,
  529. WM_QUERYOPEN = 0x0013,
  530. WM_ENDSESSION = 0x0016,
  531. WM_QUIT = 0x0012,
  532. WM_ERASEBKGND = 0x0014,
  533. WM_SYSCOLORCHANGE = 0x0015,
  534. WM_SHOWWINDOW = 0x0018,
  535. WM_WININICHANGE = 0x001A,
  536. WM_SETTINGCHANGE = WM_WININICHANGE,
  537. WM_DEVMODECHANGE = 0x001B,
  538. WM_ACTIVATEAPP = 0x001C,
  539. WM_FONTCHANGE = 0x001D,
  540. WM_TIMECHANGE = 0x001E,
  541. WM_CANCELMODE = 0x001F,
  542. WM_SETCURSOR = 0x0020,
  543. WM_MOUSEACTIVATE = 0x0021,
  544. WM_CHILDACTIVATE = 0x0022,
  545. WM_QUEUESYNC = 0x0023,
  546. WM_GETMINMAXINFO = 0x0024,
  547. WM_PAINTICON = 0x0026,
  548. WM_ICONERASEBKGND = 0x0027,
  549. WM_NEXTDLGCTL = 0x0028,
  550. WM_SPOOLERSTATUS = 0x002A,
  551. WM_DRAWITEM = 0x002B,
  552. WM_MEASUREITEM = 0x002C,
  553. WM_DELETEITEM = 0x002D,
  554. WM_VKEYTOITEM = 0x002E,
  555. WM_CHARTOITEM = 0x002F,
  556. WM_SETFONT = 0x0030,
  557. WM_GETFONT = 0x0031,
  558. WM_SETHOTKEY = 0x0032,
  559. WM_GETHOTKEY = 0x0033,
  560. WM_QUERYDRAGICON = 0x0037,
  561. WM_COMPAREITEM = 0x0039,
  562. WM_GETOBJECT = 0x003D,
  563. WM_COMPACTING = 0x0041,
  564. WM_WINDOWPOSCHANGING = 0x0046,
  565. WM_WINDOWPOSCHANGED = 0x0047,
  566. WM_COPYDATA = 0x004A,
  567. WM_CANCELJOURNAL = 0x004B,
  568. WM_NOTIFY = 0x004E,
  569. WM_INPUTLANGCHANGEREQUEST = 0x0050,
  570. WM_INPUTLANGCHANGE = 0x0051,
  571. WM_TCARD = 0x0052,
  572. WM_HELP = 0x0053,
  573. WM_USERCHANGED = 0x0054,
  574. WM_NOTIFYFORMAT = 0x0055,
  575. WM_CONTEXTMENU = 0x007B,
  576. WM_STYLECHANGING = 0x007C,
  577. WM_STYLECHANGED = 0x007D,
  578. WM_DISPLAYCHANGE = 0x007E,
  579. WM_GETICON = 0x007F,
  580. WM_SETICON = 0x0080,
  581. WM_NCCREATE = 0x0081,
  582. WM_NCDESTROY = 0x0082,
  583. WM_NCCALCSIZE = 0x0083,
  584. WM_NCHITTEST = 0x0084,
  585. WM_NCPAINT = 0x0085,
  586. WM_NCACTIVATE = 0x0086,
  587. WM_GETDLGCODE = 0x0087,
  588. WM_SYNCPAINT = 0x0088,
  589. WM_NCMOUSEMOVE = 0x00A0,
  590. WM_NCLBUTTONDOWN = 0x00A1,
  591. WM_NCLBUTTONUP = 0x00A2,
  592. WM_NCLBUTTONDBLCLK = 0x00A3,
  593. WM_NCRBUTTONDOWN = 0x00A4,
  594. WM_NCRBUTTONUP = 0x00A5,
  595. WM_NCRBUTTONDBLCLK = 0x00A6,
  596. WM_NCMBUTTONDOWN = 0x00A7,
  597. WM_NCMBUTTONUP = 0x00A8,
  598. WM_NCMBUTTONDBLCLK = 0x00A9,
  599. WM_NCXBUTTONDOWN = 0x00AB,
  600. WM_NCXBUTTONUP = 0x00AC,
  601. WM_NCXBUTTONDBLCLK = 0x00AD,
  602. WM_INPUT_DEVICE_CHANGE = 0x00FE,
  603. WM_INPUT = 0x00FF,
  604. WM_KEYFIRST = 0x0100,
  605. WM_KEYDOWN = 0x0100,
  606. WM_KEYUP = 0x0101,
  607. WM_CHAR = 0x0102,
  608. WM_DEADCHAR = 0x0103,
  609. WM_SYSKEYDOWN = 0x0104,
  610. WM_SYSKEYUP = 0x0105,
  611. WM_SYSCHAR = 0x0106,
  612. WM_SYSDEADCHAR = 0x0107,
  613. WM_UNICHAR = 0x0109,
  614. WM_KEYLAST = 0x0109,
  615. WM_IME_STARTCOMPOSITION = 0x010D,
  616. WM_IME_ENDCOMPOSITION = 0x010E,
  617. WM_IME_COMPOSITION = 0x010F,
  618. WM_IME_KEYLAST = 0x010F,
  619. WM_INITDIALOG = 0x0110,
  620. WM_COMMAND = 0x0111,
  621. WM_SYSCOMMAND = 0x0112,
  622. WM_TIMER = 0x0113,
  623. WM_HSCROLL = 0x0114,
  624. WM_VSCROLL = 0x0115,
  625. WM_INITMENU = 0x0116,
  626. WM_INITMENUPOPUP = 0x0117,
  627. WM_MENUSELECT = 0x011F,
  628. WM_MENUCHAR = 0x0120,
  629. WM_ENTERIDLE = 0x0121,
  630. WM_MENURBUTTONUP = 0x0122,
  631. WM_MENUDRAG = 0x0123,
  632. WM_MENUGETOBJECT = 0x0124,
  633. WM_UNINITMENUPOPUP = 0x0125,
  634. WM_MENUCOMMAND = 0x0126,
  635. WM_CHANGEUISTATE = 0x0127,
  636. WM_UPDATEUISTATE = 0x0128,
  637. WM_QUERYUISTATE = 0x0129,
  638. WM_CTLCOLORMSGBOX = 0x0132,
  639. WM_CTLCOLOREDIT = 0x0133,
  640. WM_CTLCOLORLISTBOX = 0x0134,
  641. WM_CTLCOLORBTN = 0x0135,
  642. WM_CTLCOLORDLG = 0x0136,
  643. WM_CTLCOLORSCROLLBAR = 0x0137,
  644. WM_CTLCOLORSTATIC = 0x0138,
  645. WM_MOUSEFIRST = 0x0200,
  646. WM_MOUSEMOVE = 0x0200,
  647. WM_LBUTTONDOWN = 0x0201,
  648. WM_LBUTTONUP = 0x0202,
  649. WM_LBUTTONDBLCLK = 0x0203,
  650. WM_RBUTTONDOWN = 0x0204,
  651. WM_RBUTTONUP = 0x0205,
  652. WM_RBUTTONDBLCLK = 0x0206,
  653. WM_MBUTTONDOWN = 0x0207,
  654. WM_MBUTTONUP = 0x0208,
  655. WM_MBUTTONDBLCLK = 0x0209,
  656. WM_MOUSEWHEEL = 0x020A,
  657. WM_XBUTTONDOWN = 0x020B,
  658. WM_XBUTTONUP = 0x020C,
  659. WM_XBUTTONDBLCLK = 0x020D,
  660. WM_MOUSEHWHEEL = 0x020E,
  661. WM_MOUSELAST = 0x020E,
  662. WM_PARENTNOTIFY = 0x0210,
  663. WM_ENTERMENULOOP = 0x0211,
  664. WM_EXITMENULOOP = 0x0212,
  665. WM_NEXTMENU = 0x0213,
  666. WM_SIZING = 0x0214,
  667. WM_CAPTURECHANGED = 0x0215,
  668. WM_MOVING = 0x0216,
  669. WM_POWERBROADCAST = 0x0218,
  670. WM_DEVICECHANGE = 0x0219,
  671. WM_MDICREATE = 0x0220,
  672. WM_MDIDESTROY = 0x0221,
  673. WM_MDIACTIVATE = 0x0222,
  674. WM_MDIRESTORE = 0x0223,
  675. WM_MDINEXT = 0x0224,
  676. WM_MDIMAXIMIZE = 0x0225,
  677. WM_MDITILE = 0x0226,
  678. WM_MDICASCADE = 0x0227,
  679. WM_MDIICONARRANGE = 0x0228,
  680. WM_MDIGETACTIVE = 0x0229,
  681. WM_MDISETMENU = 0x0230,
  682. WM_ENTERSIZEMOVE = 0x0231,
  683. WM_EXITSIZEMOVE = 0x0232,
  684. WM_DROPFILES = 0x0233,
  685. WM_MDIREFRESHMENU = 0x0234,
  686. WM_POINTERDEVICECHANGE = 0x0238,
  687. WM_POINTERDEVICEINRANGE = 0x239,
  688. WM_POINTERDEVICEOUTOFRANGE = 0x23A,
  689. WM_NCPOINTERUPDATE = 0x0241,
  690. WM_NCPOINTERDOWN = 0x0242,
  691. WM_NCPOINTERUP = 0x0243,
  692. WM_POINTERUPDATE = 0x0245,
  693. WM_POINTERDOWN = 0x0246,
  694. WM_POINTERUP = 0x0247,
  695. WM_POINTERENTER = 0x0249,
  696. WM_POINTERLEAVE = 0x024A,
  697. WM_POINTERACTIVATE = 0x024B,
  698. WM_POINTERCAPTURECHANGED = 0x024C,
  699. WM_TOUCHHITTESTING = 0x024D,
  700. WM_POINTERWHEEL = 0x024E,
  701. WM_POINTERHWHEEL = 0x024F,
  702. DM_POINTERHITTEST = 0x0250,
  703. WM_IME_SETCONTEXT = 0x0281,
  704. WM_IME_NOTIFY = 0x0282,
  705. WM_IME_CONTROL = 0x0283,
  706. WM_IME_COMPOSITIONFULL = 0x0284,
  707. WM_IME_SELECT = 0x0285,
  708. WM_IME_CHAR = 0x0286,
  709. WM_IME_REQUEST = 0x0288,
  710. WM_IME_KEYDOWN = 0x0290,
  711. WM_IME_KEYUP = 0x0291,
  712. WM_MOUSEHOVER = 0x02A1,
  713. WM_MOUSELEAVE = 0x02A3,
  714. WM_NCMOUSEHOVER = 0x02A0,
  715. WM_NCMOUSELEAVE = 0x02A2,
  716. WM_WTSSESSION_CHANGE = 0x02B1,
  717. WM_TABLET_FIRST = 0x02c0,
  718. WM_TABLET_LAST = 0x02df,
  719. WM_DPICHANGED = 0x02E0,
  720. WM_CUT = 0x0300,
  721. WM_COPY = 0x0301,
  722. WM_PASTE = 0x0302,
  723. WM_CLEAR = 0x0303,
  724. WM_UNDO = 0x0304,
  725. WM_RENDERFORMAT = 0x0305,
  726. WM_RENDERALLFORMATS = 0x0306,
  727. WM_DESTROYCLIPBOARD = 0x0307,
  728. WM_DRAWCLIPBOARD = 0x0308,
  729. WM_PAINTCLIPBOARD = 0x0309,
  730. WM_VSCROLLCLIPBOARD = 0x030A,
  731. WM_SIZECLIPBOARD = 0x030B,
  732. WM_ASKCBFORMATNAME = 0x030C,
  733. WM_CHANGECBCHAIN = 0x030D,
  734. WM_HSCROLLCLIPBOARD = 0x030E,
  735. WM_QUERYNEWPALETTE = 0x030F,
  736. WM_PALETTEISCHANGING = 0x0310,
  737. WM_PALETTECHANGED = 0x0311,
  738. WM_HOTKEY = 0x0312,
  739. WM_PRINT = 0x0317,
  740. WM_PRINTCLIENT = 0x0318,
  741. WM_APPCOMMAND = 0x0319,
  742. WM_THEMECHANGED = 0x031A,
  743. WM_CLIPBOARDUPDATE = 0x031D,
  744. WM_DWMCOMPOSITIONCHANGED = 0x031E,
  745. WM_DWMNCRENDERINGCHANGED = 0x031F,
  746. WM_DWMCOLORIZATIONCOLORCHANGED = 0x0320,
  747. WM_DWMWINDOWMAXIMIZEDCHANGE = 0x0321,
  748. WM_GETTITLEBARINFOEX = 0x033F,
  749. WM_HANDHELDFIRST = 0x0358,
  750. WM_HANDHELDLAST = 0x035F,
  751. WM_AFXFIRST = 0x0360,
  752. WM_AFXLAST = 0x037F,
  753. WM_PENWINFIRST = 0x0380,
  754. WM_PENWINLAST = 0x038F,
  755. WM_TOUCH = 0x0240,
  756. WM_APP = 0x8000,
  757. WM_USER = 0x0400,
  758. WM_DISPATCH_WORK_ITEM = WM_USER,
  759. }
  760. public enum DwmWindowAttribute : uint
  761. {
  762. DWMWA_NCRENDERING_ENABLED = 1,
  763. DWMWA_NCRENDERING_POLICY,
  764. DWMWA_TRANSITIONS_FORCEDISABLED,
  765. DWMWA_ALLOW_NCPAINT,
  766. DWMWA_CAPTION_BUTTON_BOUNDS,
  767. DWMWA_NONCLIENT_RTL_LAYOUT,
  768. DWMWA_FORCE_ICONIC_REPRESENTATION,
  769. DWMWA_FLIP3D_POLICY,
  770. DWMWA_EXTENDED_FRAME_BOUNDS,
  771. DWMWA_HAS_ICONIC_BITMAP,
  772. DWMWA_DISALLOW_PEEK,
  773. DWMWA_EXCLUDED_FROM_PEEK,
  774. DWMWA_CLOAK,
  775. DWMWA_CLOAKED,
  776. DWMWA_FREEZE_REPRESENTATION,
  777. DWMWA_PASSIVE_UPDATE_MODE,
  778. DWMWA_USE_HOSTBACKDROPBRUSH,
  779. DWMWA_USE_IMMERSIVE_DARK_MODE = 20,
  780. DWMWA_WINDOW_CORNER_PREFERENCE = 33,
  781. DWMWA_BORDER_COLOR,
  782. DWMWA_CAPTION_COLOR,
  783. DWMWA_TEXT_COLOR,
  784. DWMWA_VISIBLE_FRAME_BORDER_THICKNESS,
  785. DWMWA_LAST
  786. };
  787. public enum MapVirtualKeyMapTypes : uint
  788. {
  789. MAPVK_VK_TO_VSC = 0x00,
  790. MAPVK_VSC_TO_VK = 0x01,
  791. MAPVK_VK_TO_CHAR = 0x02,
  792. MAPVK_VSC_TO_VK_EX = 0x03,
  793. }
  794. public enum BitmapCompressionMode : uint
  795. {
  796. BI_RGB = 0,
  797. BI_RLE8 = 1,
  798. BI_RLE4 = 2,
  799. BI_BITFIELDS = 3,
  800. BI_JPEG = 4,
  801. BI_PNG = 5
  802. }
  803. public enum DIBColorTable
  804. {
  805. DIB_RGB_COLORS = 0, /* color table in RGBs */
  806. DIB_PAL_COLORS /* color table in palette indices */
  807. }
  808. public enum WindowLongParam
  809. {
  810. GWL_WNDPROC = -4,
  811. GWL_HINSTANCE = -6,
  812. GWL_HWNDPARENT = -8,
  813. GWL_ID = -12,
  814. GWL_STYLE = -16,
  815. GWL_EXSTYLE = -20,
  816. GWL_USERDATA = -21
  817. }
  818. public enum MenuCharParam
  819. {
  820. MNC_IGNORE = 0,
  821. MNC_CLOSE = 1,
  822. MNC_EXECUTE = 2,
  823. MNC_SELECT = 3
  824. }
  825. public enum SysCommands
  826. {
  827. SC_SIZE = 0xF000,
  828. SC_MOVE = 0xF010,
  829. SC_MINIMIZE = 0xF020,
  830. SC_MAXIMIZE = 0xF030,
  831. SC_NEXTWINDOW = 0xF040,
  832. SC_PREVWINDOW = 0xF050,
  833. SC_CLOSE = 0xF060,
  834. SC_VSCROLL = 0xF070,
  835. SC_HSCROLL = 0xF080,
  836. SC_MOUSEMENU = 0xF090,
  837. SC_KEYMENU = 0xF100,
  838. SC_ARRANGE = 0xF110,
  839. SC_RESTORE = 0xF120,
  840. SC_TASKLIST = 0xF130,
  841. SC_SCREENSAVE = 0xF140,
  842. SC_HOTKEY = 0xF150,
  843. SC_DEFAULT = 0xF160,
  844. SC_MONITORPOWER = 0xF170,
  845. SC_CONTEXTHELP = 0xF180,
  846. SC_SEPARATOR = 0xF00F,
  847. SCF_ISSECURE = 0x00000001,
  848. }
  849. [Flags]
  850. public enum PointerFlags
  851. {
  852. POINTER_FLAG_NONE = 0x00000000,
  853. POINTER_FLAG_NEW = 0x00000001,
  854. POINTER_FLAG_INRANGE = 0x00000002,
  855. POINTER_FLAG_INCONTACT = 0x00000004,
  856. POINTER_FLAG_FIRSTBUTTON = 0x00000010,
  857. POINTER_FLAG_SECONDBUTTON = 0x00000020,
  858. POINTER_FLAG_THIRDBUTTON = 0x00000040,
  859. POINTER_FLAG_FOURTHBUTTON = 0x00000080,
  860. POINTER_FLAG_FIFTHBUTTON = 0x00000100,
  861. POINTER_FLAG_PRIMARY = 0x00002000,
  862. POINTER_FLAG_CONFIDENCE = 0x00000400,
  863. POINTER_FLAG_CANCELED = 0x00000800,
  864. POINTER_FLAG_DOWN = 0x00010000,
  865. POINTER_FLAG_UPDATE = 0x00020000,
  866. POINTER_FLAG_UP = 0x00040000,
  867. POINTER_FLAG_WHEEL = 0x00080000,
  868. POINTER_FLAG_HWHEEL = 0x00100000,
  869. POINTER_FLAG_CAPTURECHANGED = 0x00200000,
  870. POINTER_FLAG_HASTRANSFORM = 0x00400000
  871. }
  872. public enum PointerButtonChangeType : ulong
  873. {
  874. POINTER_CHANGE_NONE,
  875. POINTER_CHANGE_FIRSTBUTTON_DOWN,
  876. POINTER_CHANGE_FIRSTBUTTON_UP,
  877. POINTER_CHANGE_SECONDBUTTON_DOWN,
  878. POINTER_CHANGE_SECONDBUTTON_UP,
  879. POINTER_CHANGE_THIRDBUTTON_DOWN,
  880. POINTER_CHANGE_THIRDBUTTON_UP,
  881. POINTER_CHANGE_FOURTHBUTTON_DOWN,
  882. POINTER_CHANGE_FOURTHBUTTON_UP,
  883. POINTER_CHANGE_FIFTHBUTTON_DOWN,
  884. POINTER_CHANGE_FIFTHBUTTON_UP
  885. }
  886. [Flags]
  887. public enum PenFlags
  888. {
  889. PEN_FLAGS_NONE = 0x00000000,
  890. PEN_FLAGS_BARREL = 0x00000001,
  891. PEN_FLAGS_INVERTED = 0x00000002,
  892. PEN_FLAGS_ERASER = 0x00000004,
  893. }
  894. [Flags]
  895. public enum PenMask
  896. {
  897. PEN_MASK_NONE = 0x00000000,
  898. PEN_MASK_PRESSURE = 0x00000001,
  899. PEN_MASK_ROTATION = 0x00000002,
  900. PEN_MASK_TILT_X = 0x00000004,
  901. PEN_MASK_TILT_Y = 0x00000008
  902. }
  903. [Flags]
  904. public enum TouchFlags
  905. {
  906. TOUCH_FLAG_NONE = 0x00000000
  907. }
  908. [Flags]
  909. public enum TouchMask
  910. {
  911. TOUCH_MASK_NONE = 0x00000000,
  912. TOUCH_MASK_CONTACTAREA = 0x00000001,
  913. TOUCH_MASK_ORIENTATION = 0x00000002,
  914. TOUCH_MASK_PRESSURE = 0x00000004,
  915. }
  916. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  917. public struct POINTER_TOUCH_INFO
  918. {
  919. public POINTER_INFO pointerInfo;
  920. public TouchFlags touchFlags;
  921. public TouchMask touchMask;
  922. public int rcContactLeft;
  923. public int rcContactTop;
  924. public int rcContactRight;
  925. public int rcContactBottom;
  926. public int rcContactRawLeft;
  927. public int rcContactRawTop;
  928. public int rcContactRawRight;
  929. public int rcContactRawBottom;
  930. public uint orientation;
  931. public uint pressure;
  932. }
  933. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  934. public struct POINTER_PEN_INFO
  935. {
  936. public POINTER_INFO pointerInfo;
  937. public PenFlags penFlags;
  938. public PenMask penMask;
  939. public uint pressure;
  940. public uint rotation;
  941. public int tiltX;
  942. public int tiltY;
  943. }
  944. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  945. public struct POINTER_INFO
  946. {
  947. public PointerInputType pointerType;
  948. public uint pointerId;
  949. public uint frameId;
  950. public PointerFlags pointerFlags;
  951. public IntPtr sourceDevice;
  952. public IntPtr hwndTarget;
  953. public int ptPixelLocationX;
  954. public int ptPixelLocationY;
  955. public int ptHimetricLocationX;
  956. public int ptHimetricLocationY;
  957. public int ptPixelLocationRawX;
  958. public int ptPixelLocationRawY;
  959. public int ptHimetricLocationRawX;
  960. public int ptHimetricLocationRawY;
  961. public uint dwTime;
  962. public uint historyCount;
  963. public int inputData;
  964. public ModifierKeys dwKeyStates;
  965. public ulong PerformanceCount;
  966. public PointerButtonChangeType ButtonChangeType;
  967. }
  968. [StructLayout(LayoutKind.Sequential)]
  969. public struct RGBQUAD
  970. {
  971. public byte rgbBlue;
  972. public byte rgbGreen;
  973. public byte rgbRed;
  974. public byte rgbReserved;
  975. }
  976. [StructLayout(LayoutKind.Sequential)]
  977. public struct BITMAPINFOHEADER
  978. {
  979. public uint biSize;
  980. public int biWidth;
  981. public int biHeight;
  982. public ushort biPlanes;
  983. public ushort biBitCount;
  984. public uint biCompression;
  985. public uint biSizeImage;
  986. public int biXPelsPerMeter;
  987. public int biYPelsPerMeter;
  988. public uint biClrUsed;
  989. public uint biClrImportant;
  990. public void Init()
  991. {
  992. biSize = (uint)sizeof(BITMAPINFOHEADER);
  993. }
  994. }
  995. [StructLayout(LayoutKind.Sequential)]
  996. public struct BITMAPINFO
  997. {
  998. // C# cannot inlay structs in structs so must expand directly here
  999. //
  1000. //[StructLayout(LayoutKind.Sequential)]
  1001. //public struct BITMAPINFOHEADER
  1002. //{
  1003. public uint biSize;
  1004. public int biWidth;
  1005. public int biHeight;
  1006. public ushort biPlanes;
  1007. public ushort biBitCount;
  1008. public BitmapCompressionMode biCompression;
  1009. public uint biSizeImage;
  1010. public int biXPelsPerMeter;
  1011. public int biYPelsPerMeter;
  1012. public uint biClrUsed;
  1013. public uint biClrImportant;
  1014. //}
  1015. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
  1016. public uint[] cols;
  1017. }
  1018. [StructLayout(LayoutKind.Sequential)]
  1019. public struct MINMAXINFO
  1020. {
  1021. public POINT ptReserved;
  1022. public POINT ptMaxSize;
  1023. public POINT ptMaxPosition;
  1024. public POINT ptMinTrackSize;
  1025. public POINT ptMaxTrackSize;
  1026. }
  1027. public const int SizeOf_BITMAPINFOHEADER = 40;
  1028. [DllImport("user32.dll", SetLastError = true)]
  1029. public static extern bool IsMouseInPointerEnabled();
  1030. [DllImport("user32.dll", SetLastError = true)]
  1031. public static extern int EnableMouseInPointer(bool enable);
  1032. [DllImport("user32.dll", SetLastError = true)]
  1033. public static extern bool GetPointerCursorId(uint pointerId, out uint cursorId);
  1034. [DllImport("user32.dll", SetLastError = true)]
  1035. public static extern bool GetPointerType(uint pointerId, out PointerInputType pointerType);
  1036. [DllImport("user32.dll", SetLastError = true)]
  1037. public static extern bool GetPointerInfo(uint pointerId, out POINTER_INFO pointerInfo);
  1038. [DllImport("user32.dll", SetLastError = true)]
  1039. public static extern bool GetPointerInfoHistory(uint pointerId, ref int entriesCount, [MarshalAs(UnmanagedType.LPArray), In, Out] POINTER_INFO[] pointerInfos);
  1040. [DllImport("user32.dll", SetLastError = true)]
  1041. public static extern bool GetPointerPenInfo(uint pointerId, out POINTER_PEN_INFO penInfo);
  1042. [DllImport("user32.dll", SetLastError = true)]
  1043. public static extern bool GetPointerPenInfoHistory(uint pointerId, ref int entriesCount, [MarshalAs(UnmanagedType.LPArray), In, Out] POINTER_PEN_INFO[] penInfos);
  1044. [DllImport("user32.dll", SetLastError = true)]
  1045. public static extern bool GetPointerTouchInfo(uint pointerId, out POINTER_TOUCH_INFO touchInfo);
  1046. [DllImport("user32.dll", SetLastError = true)]
  1047. public static extern bool GetPointerTouchInfoHistory(uint pointerId, ref int entriesCount, [MarshalAs(UnmanagedType.LPArray), In, Out] POINTER_TOUCH_INFO[] touchInfos);
  1048. [DllImport("user32.dll")]
  1049. public static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr lprcClip,
  1050. MonitorEnumDelegate lpfnEnum, IntPtr dwData);
  1051. public delegate bool MonitorEnumDelegate(IntPtr hMonitor, IntPtr hdcMonitor, ref Rect lprcMonitor, IntPtr dwData);
  1052. [DllImport("user32.dll", SetLastError = true)]
  1053. public static extern IntPtr GetDC(IntPtr hWnd);
  1054. [DllImport("gdi32.dll")]
  1055. public static extern int SetDIBitsToDevice(IntPtr hdc, int XDest, int YDest,
  1056. uint dwWidth, uint dwHeight,
  1057. int XSrc, int YSrc,
  1058. uint uStartScan, uint cScanLines,
  1059. IntPtr lpvBits, [In] ref BITMAPINFO lpbmi, uint fuColorUse);
  1060. [DllImport("user32.dll")]
  1061. public static extern bool ReleaseDC(IntPtr hWnd, IntPtr hDC);
  1062. [DllImport("user32.dll", SetLastError = true)]
  1063. public static extern bool AdjustWindowRectEx(ref RECT lpRect, uint dwStyle, bool bMenu, uint dwExStyle);
  1064. [DllImport("user32.dll")]
  1065. public static extern IntPtr BeginPaint(IntPtr hwnd, out PAINTSTRUCT lpPaint);
  1066. [DllImport("user32.dll")]
  1067. public static extern bool ClientToScreen(IntPtr hWnd, ref POINT lpPoint);
  1068. [DllImport("user32.dll", SetLastError = true)]
  1069. public static extern IntPtr CreateWindowEx(
  1070. int dwExStyle,
  1071. uint lpClassName,
  1072. string lpWindowName,
  1073. uint dwStyle,
  1074. int x,
  1075. int y,
  1076. int nWidth,
  1077. int nHeight,
  1078. IntPtr hWndParent,
  1079. IntPtr hMenu,
  1080. IntPtr hInstance,
  1081. IntPtr lpParam);
  1082. [DllImport("user32.dll", EntryPoint = "DefWindowProcW")]
  1083. public static extern IntPtr DefWindowProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
  1084. [DllImport("user32.dll", EntryPoint = "DispatchMessageW")]
  1085. public static extern IntPtr DispatchMessage(ref MSG lpmsg);
  1086. [DllImport("user32.dll", SetLastError = true)]
  1087. public static extern bool DestroyWindow(IntPtr hwnd);
  1088. [DllImport("user32.dll")]
  1089. public static extern bool EnableWindow(IntPtr hWnd, bool bEnable);
  1090. [DllImport("user32.dll")]
  1091. public static extern bool EndPaint(IntPtr hWnd, ref PAINTSTRUCT lpPaint);
  1092. [DllImport("user32.dll")]
  1093. public static extern uint GetCaretBlinkTime();
  1094. [DllImport("user32.dll")]
  1095. public static extern bool GetClientRect(IntPtr hwnd, out RECT lpRect);
  1096. [DllImport("user32.dll")]
  1097. public static extern bool GetCursorPos(out POINT lpPoint);
  1098. [DllImport("user32.dll")]
  1099. public static extern uint GetDoubleClickTime();
  1100. [DllImport("user32.dll")]
  1101. public static extern bool GetKeyboardState(byte[] lpKeyState);
  1102. [DllImport("user32.dll", EntryPoint = "MapVirtualKeyW")]
  1103. public static extern uint MapVirtualKey(uint uCode, uint uMapType);
  1104. [DllImport("user32.dll", EntryPoint = "GetMessageW", SetLastError = true)]
  1105. public static extern int GetMessage(out MSG lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax);
  1106. [DllImport("user32.dll")]
  1107. public static extern int GetMessageTime();
  1108. [DllImport("kernel32.dll")]
  1109. public static extern IntPtr GetModuleHandle(string lpModuleName);
  1110. [DllImport("user32.dll")]
  1111. public static extern int GetSystemMetrics(SystemMetric smIndex);
  1112. [DllImport("user32.dll", SetLastError = true)]
  1113. public static extern uint GetWindowLongPtr(IntPtr hWnd, int nIndex);
  1114. [DllImport("user32.dll", SetLastError = true, EntryPoint = "GetWindowLong")]
  1115. public static extern uint GetWindowLong32b(IntPtr hWnd, int nIndex);
  1116. public static uint GetWindowLong(IntPtr hWnd, int nIndex)
  1117. {
  1118. if (IntPtr.Size == 4)
  1119. {
  1120. return GetWindowLong32b(hWnd, nIndex);
  1121. }
  1122. else
  1123. {
  1124. return GetWindowLongPtr(hWnd, nIndex);
  1125. }
  1126. }
  1127. [DllImport("user32.dll", SetLastError = true, EntryPoint = "SetWindowLong")]
  1128. private static extern uint SetWindowLong32b(IntPtr hWnd, int nIndex, uint value);
  1129. [DllImport("user32.dll", SetLastError = true, EntryPoint = "SetWindowLongPtr")]
  1130. private static extern IntPtr SetWindowLong64b(IntPtr hWnd, int nIndex, IntPtr value);
  1131. public static uint SetWindowLong(IntPtr hWnd, int nIndex, uint value)
  1132. {
  1133. if (IntPtr.Size == 4)
  1134. {
  1135. return SetWindowLong32b(hWnd, nIndex, value);
  1136. }
  1137. else
  1138. {
  1139. return (uint)SetWindowLong64b(hWnd, nIndex, new IntPtr((uint)value)).ToInt32();
  1140. }
  1141. }
  1142. public static IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr handle)
  1143. {
  1144. if (IntPtr.Size == 4)
  1145. {
  1146. return new IntPtr(SetWindowLong32b(hWnd, nIndex, (uint)handle.ToInt32()));
  1147. }
  1148. else
  1149. {
  1150. return SetWindowLong64b(hWnd, nIndex, handle);
  1151. }
  1152. }
  1153. [DllImport("user32.dll")]
  1154. public static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
  1155. [DllImport("user32.dll")]
  1156. public static extern bool EnableMenuItem(IntPtr hMenu, uint uIDEnableItem, uint uEnable);
  1157. [DllImport("user32.dll", SetLastError = true)]
  1158. public static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl);
  1159. [DllImport("user32.dll")]
  1160. public static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect);
  1161. [DllImport("user32.dll")]
  1162. public static extern bool GetUpdateRect(IntPtr hwnd, out RECT lpRect, bool bErase);
  1163. [DllImport("user32.dll")]
  1164. public static extern bool InvalidateRect(IntPtr hWnd, ref RECT lpRect, bool bErase);
  1165. [DllImport("user32.dll")]
  1166. public static extern bool InvalidateRect(IntPtr hWnd, RECT* lpRect, bool bErase);
  1167. [DllImport("user32.dll")]
  1168. public static extern bool ValidateRect(IntPtr hWnd, IntPtr lpRect);
  1169. [DllImport("user32.dll")]
  1170. public static extern bool IsWindow(IntPtr hWnd);
  1171. [DllImport("user32.dll")]
  1172. public static extern bool IsWindowEnabled(IntPtr hWnd);
  1173. [DllImport("user32.dll")]
  1174. public static extern bool IsWindowUnicode(IntPtr hWnd);
  1175. [DllImport("user32.dll")]
  1176. public static extern bool IsWindowVisible(IntPtr hWnd);
  1177. [DllImport("user32.dll")]
  1178. public static extern bool KillTimer(IntPtr hWnd, IntPtr uIDEvent);
  1179. [DllImport("user32.dll")]
  1180. public static extern IntPtr LoadCursor(IntPtr hInstance, IntPtr lpCursorName);
  1181. [DllImport("user32.dll")]
  1182. public static extern IntPtr CreateIconIndirect([In] ref ICONINFO iconInfo);
  1183. [DllImport("user32.dll")]
  1184. public static extern bool DestroyIcon(IntPtr hIcon);
  1185. [DllImport("user32.dll")]
  1186. public static extern bool PeekMessage(out MSG lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax, uint wRemoveMsg);
  1187. [DllImport("user32")]
  1188. public static extern IntPtr GetMessageExtraInfo();
  1189. [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "RegisterClassExW")]
  1190. public static extern ushort RegisterClassEx(ref WNDCLASSEX lpwcx);
  1191. [DllImport("user32.dll")]
  1192. public static extern void RegisterTouchWindow(IntPtr hWnd, int flags);
  1193. [DllImport("user32.dll")]
  1194. public static extern bool ReleaseCapture();
  1195. [DllImport("user32.dll", SetLastError = true)]
  1196. public static extern uint RegisterWindowMessage(string lpString);
  1197. [DllImport("user32.dll")]
  1198. public static extern bool ScreenToClient(IntPtr hWnd, ref POINT lpPoint);
  1199. [DllImport("user32.dll", SetLastError = true)]
  1200. public static extern IntPtr GetActiveWindow();
  1201. [DllImport("user32.dll", SetLastError = true)]
  1202. public static extern IntPtr SetActiveWindow(IntPtr hWnd);
  1203. [DllImport("user32.dll", SetLastError = true)]
  1204. public static extern bool SetForegroundWindow(IntPtr hWnd);
  1205. [DllImport("user32.dll")]
  1206. public static extern IntPtr SetCapture(IntPtr hWnd);
  1207. [DllImport("user32.dll")]
  1208. public static extern IntPtr SetTimer(IntPtr hWnd, IntPtr nIDEvent, uint uElapse, TimerProc lpTimerFunc);
  1209. [DllImport("user32.dll", SetLastError = true)]
  1210. public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
  1211. [DllImport("user32.dll")]
  1212. public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, SetWindowPosFlags uFlags);
  1213. [DllImport("user32.dll")]
  1214. public static extern bool SetFocus(IntPtr hWnd);
  1215. [DllImport("user32.dll")]
  1216. public static extern IntPtr GetFocus();
  1217. [DllImport("user32.dll")]
  1218. public static extern bool SetParent(IntPtr hWnd, IntPtr hWndNewParent);
  1219. [DllImport("user32.dll")]
  1220. public static extern IntPtr GetParent(IntPtr hWnd);
  1221. public enum GetAncestorFlags
  1222. {
  1223. GA_PARENT = 1,
  1224. GA_ROOT = 2,
  1225. GA_ROOTOWNER = 3
  1226. }
  1227. [DllImport("user32.dll")]
  1228. public static extern IntPtr GetAncestor(IntPtr hwnd, GetAncestorFlags gaFlags);
  1229. [DllImport("user32.dll")]
  1230. public static extern bool ShowWindow(IntPtr hWnd, ShowWindowCommand nCmdShow);
  1231. [DllImport("kernel32.dll", SetLastError = true)]
  1232. public static extern IntPtr CreateTimerQueue();
  1233. [DllImport("kernel32.dll", SetLastError = true)]
  1234. public static extern bool DeleteTimerQueueEx(IntPtr TimerQueue, IntPtr CompletionEvent);
  1235. [DllImport("kernel32.dll", SetLastError = true)]
  1236. [return: MarshalAs(UnmanagedType.Bool)]
  1237. public static extern bool CreateTimerQueueTimer(
  1238. out IntPtr phNewTimer,
  1239. IntPtr TimerQueue,
  1240. WaitOrTimerCallback Callback,
  1241. IntPtr Parameter,
  1242. uint DueTime,
  1243. uint Period,
  1244. uint Flags);
  1245. [DllImport("kernel32.dll", SetLastError = true)]
  1246. public static extern bool DeleteTimerQueueTimer(IntPtr TimerQueue, IntPtr Timer, IntPtr CompletionEvent);
  1247. [DllImport("user32.dll")]
  1248. public static extern int ToUnicode(
  1249. uint virtualKeyCode,
  1250. uint scanCode,
  1251. byte[] keyboardState,
  1252. [Out, MarshalAs(UnmanagedType.LPWStr, SizeConst = 64)]
  1253. StringBuilder receivingBuffer,
  1254. int bufferSize,
  1255. uint flags);
  1256. [DllImport("user32.dll", SetLastError = true)]
  1257. public static extern bool TrackMouseEvent(ref TRACKMOUSEEVENT lpEventTrack);
  1258. [DllImport("user32.dll")]
  1259. public static extern bool TranslateMessage(ref MSG lpMsg);
  1260. [DllImport("user32.dll")]
  1261. public static extern bool UnregisterClass(string lpClassName, IntPtr hInstance);
  1262. [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "SetWindowTextW")]
  1263. public static extern bool SetWindowText(IntPtr hwnd, string lpString);
  1264. public enum ClassLongIndex : int
  1265. {
  1266. GCLP_MENUNAME = -8,
  1267. GCLP_HBRBACKGROUND = -10,
  1268. GCLP_HCURSOR = -12,
  1269. GCLP_HICON = -14,
  1270. GCLP_HMODULE = -16,
  1271. GCL_CBWNDEXTRA = -18,
  1272. GCL_CBCLSEXTRA = -20,
  1273. GCLP_WNDPROC = -24,
  1274. GCL_STYLE = -26,
  1275. GCLP_HICONSM = -34,
  1276. GCW_ATOM = -32
  1277. }
  1278. [DllImport("shell32", CharSet = CharSet.Auto)]
  1279. public static extern int Shell_NotifyIcon(NIM dwMessage, NOTIFYICONDATA lpData);
  1280. [DllImport("user32.dll", EntryPoint = "SetClassLongPtr")]
  1281. private static extern IntPtr SetClassLong64(IntPtr hWnd, ClassLongIndex nIndex, IntPtr dwNewLong);
  1282. [DllImport("user32.dll", EntryPoint = "SetClassLong")]
  1283. private static extern IntPtr SetClassLong32(IntPtr hWnd, ClassLongIndex nIndex, IntPtr dwNewLong);
  1284. public static IntPtr SetClassLong(IntPtr hWnd, ClassLongIndex nIndex, IntPtr dwNewLong)
  1285. {
  1286. if (IntPtr.Size == 4)
  1287. {
  1288. return SetClassLong32(hWnd, nIndex, dwNewLong);
  1289. }
  1290. return SetClassLong64(hWnd, nIndex, dwNewLong);
  1291. }
  1292. public static IntPtr GetClassLongPtr(IntPtr hWnd, int nIndex)
  1293. {
  1294. if (IntPtr.Size > 4)
  1295. return GetClassLongPtr64(hWnd, nIndex);
  1296. else
  1297. return new IntPtr(GetClassLongPtr32(hWnd, nIndex));
  1298. }
  1299. [DllImport("user32.dll", EntryPoint = "GetClassLong")]
  1300. public static extern uint GetClassLongPtr32(IntPtr hWnd, int nIndex);
  1301. [DllImport("user32.dll", EntryPoint = "GetClassLongPtr")]
  1302. public static extern IntPtr GetClassLongPtr64(IntPtr hWnd, int nIndex);
  1303. [DllImport("user32.dll", EntryPoint = "SetCursor")]
  1304. internal static extern IntPtr SetCursor(IntPtr hCursor);
  1305. [DllImport("ole32.dll", PreserveSig = true)]
  1306. internal static extern int CoCreateInstance(ref Guid clsid,
  1307. IntPtr ignore1, int ignore2, ref Guid iid, [MarshalAs(UnmanagedType.IUnknown), Out] out object pUnkOuter);
  1308. [DllImport("ole32.dll", PreserveSig = true)]
  1309. internal static extern int CoCreateInstance(ref Guid clsid,
  1310. IntPtr ignore1, int ignore2, ref Guid iid, [Out] out IntPtr pUnkOuter);
  1311. internal unsafe static T CreateInstance<T>(ref Guid clsid, ref Guid iid) where T : IUnknown
  1312. {
  1313. var hresult = CoCreateInstance(ref clsid, IntPtr.Zero, 1, ref iid, out IntPtr pUnk);
  1314. if (hresult != 0)
  1315. {
  1316. throw new COMException("CreateInstance", hresult);
  1317. }
  1318. using var unk = MicroComRuntime.CreateProxyFor<IUnknown>(pUnk, true);
  1319. return MicroComRuntime.QueryInterface<T>(unk);
  1320. }
  1321. [DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
  1322. internal static extern int SHCreateItemFromParsingName([MarshalAs(UnmanagedType.LPWStr)] string pszPath, IntPtr pbc, ref Guid riid, out IntPtr ppv);
  1323. [DllImport("user32.dll", SetLastError = true)]
  1324. public static extern bool OpenClipboard(IntPtr hWndOwner);
  1325. [DllImport("user32.dll", SetLastError = true)]
  1326. public static extern bool CloseClipboard();
  1327. [DllImport("user32.dll")]
  1328. public static extern bool EmptyClipboard();
  1329. [DllImport("user32.dll")]
  1330. public static extern IntPtr GetClipboardData(ClipboardFormat uFormat);
  1331. [DllImport("user32.dll")]
  1332. public static extern IntPtr SetClipboardData(ClipboardFormat uFormat, IntPtr hMem);
  1333. [DllImport("ole32.dll", PreserveSig = false)]
  1334. public static extern int OleGetClipboard(out IntPtr dataObject);
  1335. [DllImport("ole32.dll", PreserveSig = true)]
  1336. public static extern int OleSetClipboard(IntPtr dataObject);
  1337. [DllImport("kernel32.dll", ExactSpelling = true)]
  1338. public static extern IntPtr GlobalLock(IntPtr handle);
  1339. [DllImport("kernel32.dll", ExactSpelling = true)]
  1340. public static extern bool GlobalUnlock(IntPtr handle);
  1341. [DllImport("kernel32.dll", ExactSpelling = true)]
  1342. public static extern IntPtr GlobalAlloc(int uFlags, int dwBytes);
  1343. [DllImport("kernel32.dll", ExactSpelling = true)]
  1344. public static extern IntPtr GlobalFree(IntPtr hMem);
  1345. [DllImport("kernel32.dll", SetLastError = true)]
  1346. public static extern IntPtr LoadLibrary(string fileName);
  1347. [DllImport("kernel32.dll", SetLastError = true)]
  1348. public static extern IntPtr LoadLibraryEx(string fileName, IntPtr hFile, int flags);
  1349. [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi)]
  1350. public static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName);
  1351. [DllImport("comdlg32.dll", CharSet = CharSet.Unicode, EntryPoint = "GetSaveFileNameW")]
  1352. public static extern bool GetSaveFileName(IntPtr lpofn);
  1353. [DllImport("comdlg32.dll", CharSet = CharSet.Unicode, EntryPoint = "GetOpenFileNameW")]
  1354. public static extern bool GetOpenFileName(IntPtr lpofn);
  1355. [DllImport("comdlg32.dll")]
  1356. public static extern int CommDlgExtendedError();
  1357. public static bool ShCoreAvailable => LoadLibrary("shcore.dll") != IntPtr.Zero;
  1358. [DllImport("shcore.dll")]
  1359. public static extern void SetProcessDpiAwareness(PROCESS_DPI_AWARENESS value);
  1360. [DllImport("user32.dll", SetLastError = true)]
  1361. public static extern bool SetProcessDpiAwarenessContext(IntPtr dpiAWarenessContext);
  1362. [DllImport("shcore.dll")]
  1363. public static extern long GetDpiForMonitor(IntPtr hmonitor, MONITOR_DPI_TYPE dpiType, out uint dpiX, out uint dpiY);
  1364. [DllImport("gdi32.dll")]
  1365. public static extern int GetDeviceCaps(IntPtr hdc, DEVICECAP nIndex);
  1366. [DllImport("shcore.dll")]
  1367. public static extern void GetScaleFactorForMonitor(IntPtr hMon, out uint pScale);
  1368. [DllImport("user32.dll", SetLastError = true)]
  1369. public static extern bool SetProcessDPIAware();
  1370. [DllImport("user32.dll")]
  1371. public static extern IntPtr MonitorFromPoint(POINT pt, MONITOR dwFlags);
  1372. [DllImport("user32.dll")]
  1373. public static extern IntPtr MonitorFromRect(RECT rect, MONITOR dwFlags);
  1374. [DllImport("user32.dll")]
  1375. public static extern IntPtr MonitorFromWindow(IntPtr hwnd, MONITOR dwFlags);
  1376. [DllImport("user32", EntryPoint = "GetMonitorInfoW", ExactSpelling = true, CharSet = CharSet.Unicode)]
  1377. [return: MarshalAs(UnmanagedType.Bool)]
  1378. public static extern bool GetMonitorInfo([In] IntPtr hMonitor, ref MONITORINFO lpmi);
  1379. [DllImport("user32")]
  1380. public static extern unsafe bool GetTouchInputInfo(
  1381. IntPtr hTouchInput,
  1382. uint cInputs,
  1383. TOUCHINPUT* pInputs,
  1384. int cbSize
  1385. );
  1386. [DllImport("user32")]
  1387. public static extern bool CloseTouchInputHandle(IntPtr hTouchInput);
  1388. [return: MarshalAs(UnmanagedType.Bool)]
  1389. [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "PostMessageW")]
  1390. public static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
  1391. [DllImport("gdi32.dll")]
  1392. public static extern int SetDIBitsToDevice(IntPtr hdc, int XDest, int YDest, uint
  1393. dwWidth, uint dwHeight, int XSrc, int YSrc, uint uStartScan, uint cScanLines,
  1394. IntPtr lpvBits, [In] ref BITMAPINFOHEADER lpbmi, uint fuColorUse);
  1395. [DllImport("kernel32.dll", SetLastError = true)]
  1396. [return: MarshalAs(UnmanagedType.Bool)]
  1397. public static extern bool CloseHandle(IntPtr hObject);
  1398. [DllImport("gdi32.dll", SetLastError = true)]
  1399. public static extern IntPtr CreateDIBSection(IntPtr hDC, ref BITMAPINFOHEADER pBitmapInfo, int un, out IntPtr lplpVoid, IntPtr handle, int dw);
  1400. [DllImport("gdi32.dll")]
  1401. public static extern int DeleteObject(IntPtr hObject);
  1402. [DllImport("gdi32.dll", SetLastError = true)]
  1403. public static extern IntPtr CreateCompatibleDC(IntPtr hdc);
  1404. [DllImport("gdi32.dll")]
  1405. public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hObject);
  1406. [DllImport("gdi32.dll")]
  1407. public static extern int ChoosePixelFormat(IntPtr hdc, ref PixelFormatDescriptor pfd);
  1408. [DllImport("gdi32.dll")]
  1409. public static extern int DescribePixelFormat(IntPtr hdc, ref PixelFormatDescriptor pfd);
  1410. [DllImport("gdi32.dll")]
  1411. public static extern int SetPixelFormat(IntPtr hdc, int iPixelFormat, ref PixelFormatDescriptor pfd);
  1412. [DllImport("gdi32.dll")]
  1413. public static extern int DescribePixelFormat(IntPtr hdc, int iPixelFormat, int bytes, ref PixelFormatDescriptor pfd);
  1414. [DllImport("gdi32.dll")]
  1415. public static extern bool SwapBuffers(IntPtr hdc);
  1416. [DllImport("opengl32.dll")]
  1417. public static extern IntPtr wglCreateContext(IntPtr hdc);
  1418. [DllImport("opengl32.dll")]
  1419. public static extern bool wglDeleteContext(IntPtr context);
  1420. [DllImport("opengl32.dll")]
  1421. public static extern bool wglMakeCurrent(IntPtr hdc, IntPtr context);
  1422. [DllImport("opengl32.dll")]
  1423. public static extern IntPtr wglGetCurrentContext();
  1424. [DllImport("opengl32.dll")]
  1425. public static extern IntPtr wglGetCurrentDC();
  1426. [DllImport("opengl32.dll", CharSet = CharSet.Ansi)]
  1427. public static extern IntPtr wglGetProcAddress(string name);
  1428. [DllImport("kernel32.dll", SetLastError = true)]
  1429. public static extern IntPtr CreateFileMapping(IntPtr hFile,
  1430. IntPtr lpFileMappingAttributes,
  1431. uint flProtect,
  1432. uint dwMaximumSizeHigh,
  1433. uint dwMaximumSizeLow,
  1434. string lpName);
  1435. [DllImport("msvcrt.dll", EntryPoint = "memcpy", SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
  1436. public static extern IntPtr CopyMemory(IntPtr dest, IntPtr src, UIntPtr count);
  1437. [DllImport("ole32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
  1438. public static extern HRESULT RegisterDragDrop(IntPtr hwnd, IntPtr target);
  1439. [DllImport("ole32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
  1440. public static extern HRESULT RevokeDragDrop(IntPtr hwnd);
  1441. [DllImport("ole32.dll", EntryPoint = "OleInitialize")]
  1442. public static extern HRESULT OleInitialize(IntPtr val);
  1443. [DllImport("ole32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
  1444. internal static extern void ReleaseStgMedium(ref STGMEDIUM medium);
  1445. [DllImport("user32.dll", BestFitMapping = false, CharSet = CharSet.Auto, SetLastError = true)]
  1446. public static extern int GetClipboardFormatName(int format, StringBuilder lpString, int cchMax);
  1447. [DllImport("user32.dll", BestFitMapping = false, CharSet = CharSet.Auto, SetLastError = true)]
  1448. public static extern int RegisterClipboardFormat(string format);
  1449. [DllImport("kernel32.dll", CharSet = CharSet.Auto, ExactSpelling = true, SetLastError = true)]
  1450. public static extern IntPtr GlobalSize(IntPtr hGlobal);
  1451. [DllImport("shell32.dll", BestFitMapping = false, CharSet = CharSet.Auto)]
  1452. public static extern int DragQueryFile(IntPtr hDrop, int iFile, StringBuilder lpszFile, int cch);
  1453. [DllImport("ole32.dll", CharSet = CharSet.Auto, ExactSpelling = true, PreserveSig = false)]
  1454. internal static extern void DoDragDrop(IntPtr dataObject, IntPtr dropSource, int allowedEffects, [Out] out int finalEffect);
  1455. [DllImport("dwmapi.dll")]
  1456. public static extern int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins);
  1457. [DllImport("dwmapi.dll")]
  1458. public static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, out RECT pvAttribute, int cbAttribute);
  1459. [DllImport("dwmapi.dll")]
  1460. public static extern int DwmSetWindowAttribute(IntPtr hwnd, int dwAttribute, void* pvAttribute, int cbAttribute);
  1461. [DllImport("dwmapi.dll")]
  1462. public static extern int DwmIsCompositionEnabled(out bool enabled);
  1463. [DllImport("dwmapi.dll")]
  1464. public static extern void DwmFlush();
  1465. [DllImport("dwmapi.dll")]
  1466. public static extern bool DwmDefWindowProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam, ref IntPtr plResult);
  1467. [DllImport("dwmapi.dll")]
  1468. public static extern void DwmEnableBlurBehindWindow(IntPtr hwnd, ref DWM_BLURBEHIND blurBehind);
  1469. [Flags]
  1470. public enum LayeredWindowFlags
  1471. {
  1472. LWA_ALPHA = 0x00000002,
  1473. LWA_COLORKEY = 0x00000001,
  1474. }
  1475. [DllImport("user32.dll")]
  1476. public static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, LayeredWindowFlags dwFlags);
  1477. [Flags]
  1478. public enum DWM_BB
  1479. {
  1480. Enable = 1,
  1481. BlurRegion = 2,
  1482. TransitionMaximized = 4
  1483. }
  1484. [StructLayout(LayoutKind.Sequential)]
  1485. public struct DWM_BLURBEHIND
  1486. {
  1487. public DWM_BB dwFlags;
  1488. public bool fEnable;
  1489. public IntPtr hRgnBlur;
  1490. public bool fTransitionOnMaximized;
  1491. public DWM_BLURBEHIND(bool enabled)
  1492. {
  1493. fEnable = enabled ? true : false;
  1494. hRgnBlur = IntPtr.Zero;
  1495. fTransitionOnMaximized = false;
  1496. dwFlags = DWM_BB.Enable;
  1497. }
  1498. }
  1499. [StructLayout(LayoutKind.Sequential)]
  1500. internal struct RTL_OSVERSIONINFOEX
  1501. {
  1502. internal uint dwOSVersionInfoSize;
  1503. internal uint dwMajorVersion;
  1504. internal uint dwMinorVersion;
  1505. internal uint dwBuildNumber;
  1506. internal uint dwPlatformId;
  1507. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
  1508. internal string szCSDVersion;
  1509. }
  1510. [DllImport("ntdll")]
  1511. private static extern int RtlGetVersion(ref RTL_OSVERSIONINFOEX lpVersionInformation);
  1512. internal static Version RtlGetVersion()
  1513. {
  1514. RTL_OSVERSIONINFOEX v = new RTL_OSVERSIONINFOEX();
  1515. v.dwOSVersionInfoSize = (uint)Marshal.SizeOf<RTL_OSVERSIONINFOEX>();
  1516. if (RtlGetVersion(ref v) == 0)
  1517. {
  1518. return new Version((int)v.dwMajorVersion, (int)v.dwMinorVersion, (int)v.dwBuildNumber);
  1519. }
  1520. else
  1521. {
  1522. throw new Exception("RtlGetVersion failed!");
  1523. }
  1524. }
  1525. [DllImport("kernel32", EntryPoint = "WaitForMultipleObjectsEx", SetLastError = true, CharSet = CharSet.Auto)]
  1526. private static extern int IntWaitForMultipleObjectsEx(int nCount, IntPtr[] pHandles, bool bWaitAll, int dwMilliseconds, bool bAlertable);
  1527. public const int WAIT_FAILED = unchecked((int)0xFFFFFFFF);
  1528. internal static int WaitForMultipleObjectsEx(int nCount, IntPtr[] pHandles, bool bWaitAll, int dwMilliseconds, bool bAlertable)
  1529. {
  1530. int result = IntWaitForMultipleObjectsEx(nCount, pHandles, bWaitAll, dwMilliseconds, bAlertable);
  1531. if (result == WAIT_FAILED)
  1532. {
  1533. throw new Win32Exception();
  1534. }
  1535. return result;
  1536. }
  1537. [DllImport("user32.dll")]
  1538. internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
  1539. [DllImport("imm32.dll", SetLastError = true)]
  1540. public static extern IntPtr ImmGetContext(IntPtr hWnd);
  1541. [DllImport("imm32.dll", SetLastError = true)]
  1542. public static extern IntPtr ImmAssociateContext(IntPtr hWnd, IntPtr hIMC);
  1543. [DllImport("imm32.dll", SetLastError = true)]
  1544. public static extern IntPtr ImmCreateContext();
  1545. [DllImport("imm32.dll")]
  1546. public static extern bool ImmReleaseContext(IntPtr hWnd, IntPtr hIMC);
  1547. [DllImport("imm32.dll")]
  1548. public static extern bool ImmSetOpenStatus(IntPtr hIMC, bool flag);
  1549. [DllImport("imm32.dll")]
  1550. public static extern bool ImmSetActiveContext(IntPtr hIMC, bool flag);
  1551. [DllImport("imm32.dll")]
  1552. public static extern bool ImmSetStatusWindowPos(IntPtr hIMC, ref POINT lpptPos);
  1553. [DllImport("imm32.dll")]
  1554. public static extern bool ImmIsIME(IntPtr HKL);
  1555. [DllImport("imm32.dll")]
  1556. public static extern bool ImmSetCandidateWindow(IntPtr hIMC, ref CANDIDATEFORM lpCandidate);
  1557. [DllImport("imm32.dll")]
  1558. public static extern bool ImmSetCompositionWindow(IntPtr hIMC, ref COMPOSITIONFORM lpComp);
  1559. [DllImport("imm32.dll")]
  1560. public static extern bool ImmSetCompositionFont(IntPtr hIMC, ref LOGFONT lf);
  1561. [DllImport("imm32.dll")]
  1562. public static extern bool ImmNotifyIME(IntPtr hIMC, int dwAction, int dwIndex, int dwValue);
  1563. [DllImport("user32.dll")]
  1564. public static extern bool CreateCaret(IntPtr hwnd, IntPtr hBitmap, int nWidth, int nHeight);
  1565. [DllImport("user32.dll")]
  1566. public static extern bool SetCaretPos(int X, int Y);
  1567. [DllImport("user32.dll")]
  1568. public static extern bool DestroyCaret();
  1569. [DllImport("user32.dll")]
  1570. public static extern IntPtr GetKeyboardLayout(int idThread);
  1571. [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
  1572. public static extern int LCIDToLocaleName(uint Locale, StringBuilder lpName, int cchName, int dwFlags);
  1573. public static uint MAKELCID(uint lgid, uint srtid)
  1574. {
  1575. return (((uint)(ushort)srtid) << 16) |
  1576. ((ushort)lgid);
  1577. }
  1578. public static ushort PRIMARYLANGID(uint lgid)
  1579. {
  1580. return (ushort)(lgid & 0x3ff);
  1581. }
  1582. public static uint LGID(IntPtr HKL)
  1583. {
  1584. return (uint)(HKL.ToInt32() & 0xffff);
  1585. }
  1586. public const int SORT_DEFAULT = 0;
  1587. public const int LANG_ZH = 0x0004;
  1588. public const int LANG_JA = 0x0011;
  1589. public const int LANG_KO = 0x0012;
  1590. public const int CFS_FORCE_POSITION = 0x0020;
  1591. public const int CFS_CANDIDATEPOS = 0x0040;
  1592. public const int CFS_EXCLUDE = 0x0080;
  1593. public const int CFS_POINT = 0x0002;
  1594. public const int CFS_RECT = 0x0001;
  1595. public const uint ISC_SHOWUICOMPOSITIONWINDOW = 0x80000000;
  1596. public const int NI_COMPOSITIONSTR = 21;
  1597. public const int CPS_COMPLETE = 1;
  1598. public const int CPS_CONVERT = 2;
  1599. public const int CPS_REVERT = 3;
  1600. public const int CPS_CANCEL = 4;
  1601. [StructLayout(LayoutKind.Sequential)]
  1602. internal struct CANDIDATEFORM
  1603. {
  1604. public int dwIndex;
  1605. public int dwStyle;
  1606. public POINT ptCurrentPos;
  1607. public RECT rcArea;
  1608. }
  1609. [StructLayout(LayoutKind.Sequential)]
  1610. internal struct COMPOSITIONFORM
  1611. {
  1612. public int dwStyle;
  1613. public POINT ptCurrentPos;
  1614. public RECT rcArea;
  1615. }
  1616. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
  1617. public struct LOGFONT
  1618. {
  1619. public int lfHeight;
  1620. public int lfWidth;
  1621. public int lfEscapement;
  1622. public int lfOrientation;
  1623. public int lfWeight;
  1624. public byte lfItalic;
  1625. public byte lfUnderline;
  1626. public byte lfStrikeOut;
  1627. public byte lfCharSet;
  1628. public byte lfOutPrecision;
  1629. public byte lfClipPrecision;
  1630. public byte lfQuality;
  1631. public byte lfPitchAndFamily;
  1632. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
  1633. public string lfFaceName;
  1634. }
  1635. [StructLayout(LayoutKind.Sequential)]
  1636. internal struct WindowCompositionAttributeData
  1637. {
  1638. public WindowCompositionAttribute Attribute;
  1639. public IntPtr Data;
  1640. public int SizeOfData;
  1641. }
  1642. internal enum WindowCompositionAttribute
  1643. {
  1644. // ...
  1645. WCA_ACCENT_POLICY = 19
  1646. // ...
  1647. }
  1648. internal enum AccentState
  1649. {
  1650. ACCENT_DISABLED = 0,
  1651. ACCENT_ENABLE_GRADIENT = 1,
  1652. ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
  1653. ACCENT_ENABLE_BLURBEHIND = 3,
  1654. ACCENT_ENABLE_ACRYLIC = 4, //1703 and above
  1655. ACCENT_ENABLE_HOSTBACKDROP = 5, // RS5 1809
  1656. ACCENT_INVALID_STATE = 6
  1657. }
  1658. internal enum AccentFlags
  1659. {
  1660. DrawLeftBorder = 0x20,
  1661. DrawTopBorder = 0x40,
  1662. DrawRightBorder = 0x80,
  1663. DrawBottomBorder = 0x100,
  1664. }
  1665. [StructLayout(LayoutKind.Sequential)]
  1666. internal struct AccentPolicy
  1667. {
  1668. public AccentState AccentState;
  1669. public int AccentFlags;
  1670. public int GradientColor;
  1671. public int AnimationId;
  1672. }
  1673. [StructLayout(LayoutKind.Sequential)]
  1674. internal struct MARGINS
  1675. {
  1676. public int cxLeftWidth;
  1677. public int cxRightWidth;
  1678. public int cyTopHeight;
  1679. public int cyBottomHeight;
  1680. }
  1681. public enum MONITOR
  1682. {
  1683. MONITOR_DEFAULTTONULL = 0x00000000,
  1684. MONITOR_DEFAULTTOPRIMARY = 0x00000001,
  1685. MONITOR_DEFAULTTONEAREST = 0x00000002,
  1686. }
  1687. [StructLayout(LayoutKind.Sequential)]
  1688. internal struct MONITORINFO
  1689. {
  1690. public int cbSize;
  1691. public RECT rcMonitor;
  1692. public RECT rcWork;
  1693. public int dwFlags;
  1694. public static MONITORINFO Create()
  1695. {
  1696. return new MONITORINFO() { cbSize = Marshal.SizeOf<MONITORINFO>() };
  1697. }
  1698. public enum MonitorOptions : uint
  1699. {
  1700. MONITOR_DEFAULTTONULL = 0x00000000,
  1701. MONITOR_DEFAULTTOPRIMARY = 0x00000001,
  1702. MONITOR_DEFAULTTONEAREST = 0x00000002
  1703. }
  1704. }
  1705. public enum DEVICECAP
  1706. {
  1707. HORZRES = 8,
  1708. DESKTOPHORZRES = 118
  1709. }
  1710. public enum PROCESS_DPI_AWARENESS
  1711. {
  1712. PROCESS_DPI_UNAWARE = 0,
  1713. PROCESS_SYSTEM_DPI_AWARE = 1,
  1714. PROCESS_PER_MONITOR_DPI_AWARE = 2
  1715. }
  1716. public enum MONITOR_DPI_TYPE
  1717. {
  1718. MDT_EFFECTIVE_DPI = 0,
  1719. MDT_ANGULAR_DPI = 1,
  1720. MDT_RAW_DPI = 2,
  1721. MDT_DEFAULT = MDT_EFFECTIVE_DPI
  1722. }
  1723. public enum ClipboardFormat
  1724. {
  1725. /// <summary>
  1726. /// Text format. Each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data. Use this format for ANSI text.
  1727. /// </summary>
  1728. CF_TEXT = 1,
  1729. /// <summary>
  1730. /// A handle to a bitmap
  1731. /// </summary>
  1732. CF_BITMAP = 2,
  1733. /// <summary>
  1734. /// A memory object containing a BITMAPINFO structure followed by the bitmap bits.
  1735. /// </summary>
  1736. CF_DIB = 3,
  1737. /// <summary>
  1738. /// Unicode text format. Each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data.
  1739. /// </summary>
  1740. CF_UNICODETEXT = 13,
  1741. /// <summary>
  1742. /// A handle to type HDROP that identifies a list of files.
  1743. /// </summary>
  1744. CF_HDROP = 15,
  1745. }
  1746. public struct MSG
  1747. {
  1748. public IntPtr hwnd;
  1749. public uint message;
  1750. public IntPtr wParam;
  1751. public IntPtr lParam;
  1752. public uint time;
  1753. public POINT pt;
  1754. }
  1755. [StructLayout(LayoutKind.Sequential)]
  1756. public struct PAINTSTRUCT
  1757. {
  1758. public IntPtr hdc;
  1759. public bool fErase;
  1760. public RECT rcPaint;
  1761. public bool fRestore;
  1762. public bool fIncUpdate;
  1763. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
  1764. public byte[] rgbReserved;
  1765. }
  1766. public struct POINT
  1767. {
  1768. public int X;
  1769. public int Y;
  1770. }
  1771. public struct SIZE
  1772. {
  1773. public int X;
  1774. public int Y;
  1775. }
  1776. public struct RECT
  1777. {
  1778. public int left;
  1779. public int top;
  1780. public int right;
  1781. public int bottom;
  1782. public int Width => right - left;
  1783. public int Height => bottom - top;
  1784. public RECT(Rect rect)
  1785. {
  1786. left = (int)rect.X;
  1787. top = (int)rect.Y;
  1788. right = (int)(rect.X + rect.Width);
  1789. bottom = (int)(rect.Y + rect.Height);
  1790. }
  1791. public void Offset(POINT pt)
  1792. {
  1793. left += pt.X;
  1794. right += pt.X;
  1795. top += pt.Y;
  1796. bottom += pt.Y;
  1797. }
  1798. }
  1799. [StructLayout(LayoutKind.Sequential)]
  1800. public struct WINDOWPOS
  1801. {
  1802. public IntPtr hwnd;
  1803. public IntPtr hwndInsertAfter;
  1804. public int x;
  1805. public int y;
  1806. public int cx;
  1807. public int cy;
  1808. public uint flags;
  1809. }
  1810. [StructLayout(LayoutKind.Sequential)]
  1811. public struct NCCALCSIZE_PARAMS
  1812. {
  1813. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
  1814. public RECT[] rgrc;
  1815. public WINDOWPOS lppos;
  1816. }
  1817. public struct TRACKMOUSEEVENT
  1818. {
  1819. public int cbSize;
  1820. public uint dwFlags;
  1821. public IntPtr hwndTrack;
  1822. public int dwHoverTime;
  1823. }
  1824. [StructLayout(LayoutKind.Sequential)]
  1825. public struct WINDOWPLACEMENT
  1826. {
  1827. /// <summary>
  1828. /// The length of the structure, in bytes. Before calling the GetWindowPlacement or SetWindowPlacement functions, set this member to sizeof(WINDOWPLACEMENT).
  1829. /// <para>
  1830. /// GetWindowPlacement and SetWindowPlacement fail if this member is not set correctly.
  1831. /// </para>
  1832. /// </summary>
  1833. public int Length;
  1834. /// <summary>
  1835. /// Specifies flags that control the position of the minimized window and the method by which the window is restored.
  1836. /// </summary>
  1837. public int Flags;
  1838. /// <summary>
  1839. /// The current show state of the window.
  1840. /// </summary>
  1841. public ShowWindowCommand ShowCmd;
  1842. /// <summary>
  1843. /// The coordinates of the window's upper-left corner when the window is minimized.
  1844. /// </summary>
  1845. public POINT MinPosition;
  1846. /// <summary>
  1847. /// The coordinates of the window's upper-left corner when the window is maximized.
  1848. /// </summary>
  1849. public POINT MaxPosition;
  1850. /// <summary>
  1851. /// The window's coordinates when the window is in the restored position.
  1852. /// </summary>
  1853. public RECT NormalPosition;
  1854. /// <summary>
  1855. /// Gets the default (empty) value.
  1856. /// </summary>
  1857. public static WINDOWPLACEMENT Default
  1858. {
  1859. get
  1860. {
  1861. WINDOWPLACEMENT result = new WINDOWPLACEMENT();
  1862. result.Length = Marshal.SizeOf<WINDOWPLACEMENT>();
  1863. return result;
  1864. }
  1865. }
  1866. }
  1867. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
  1868. public struct WNDCLASSEX
  1869. {
  1870. public int cbSize;
  1871. public int style;
  1872. public WndProc lpfnWndProc;
  1873. public int cbClsExtra;
  1874. public int cbWndExtra;
  1875. public IntPtr hInstance;
  1876. public IntPtr hIcon;
  1877. public IntPtr hCursor;
  1878. public IntPtr hbrBackground;
  1879. public string lpszMenuName;
  1880. public string lpszClassName;
  1881. public IntPtr hIconSm;
  1882. }
  1883. [StructLayout(LayoutKind.Sequential)]
  1884. public struct TOUCHINPUT
  1885. {
  1886. public int X;
  1887. public int Y;
  1888. public IntPtr Source;
  1889. public uint Id;
  1890. public TouchInputFlags Flags;
  1891. public int Mask;
  1892. public uint Time;
  1893. public IntPtr ExtraInfo;
  1894. public int CxContact;
  1895. public int CyContact;
  1896. }
  1897. [StructLayout(LayoutKind.Sequential)]
  1898. public struct ICONINFO
  1899. {
  1900. public bool IsIcon;
  1901. public int xHotspot;
  1902. public int yHotspot;
  1903. public IntPtr MaskBitmap;
  1904. public IntPtr ColorBitmap;
  1905. };
  1906. [Flags]
  1907. public enum TouchInputFlags
  1908. {
  1909. /// <summary>
  1910. /// Movement has occurred. Cannot be combined with TOUCHEVENTF_DOWN.
  1911. /// </summary>
  1912. TOUCHEVENTF_MOVE = 0x0001,
  1913. /// <summary>
  1914. /// The corresponding touch point was established through a new contact. Cannot be combined with TOUCHEVENTF_MOVE or TOUCHEVENTF_UP.
  1915. /// </summary>
  1916. TOUCHEVENTF_DOWN = 0x0002,
  1917. /// <summary>
  1918. /// A touch point was removed.
  1919. /// </summary>
  1920. TOUCHEVENTF_UP = 0x0004,
  1921. /// <summary>
  1922. /// A touch point is in range. This flag is used to enable touch hover support on compatible hardware. Applications that do not want support for hover can ignore this flag.
  1923. /// </summary>
  1924. TOUCHEVENTF_INRANGE = 0x0008,
  1925. /// <summary>
  1926. /// Indicates that this TOUCHINPUT structure corresponds to a primary contact point. See the following text for more information on primary touch points.
  1927. /// </summary>
  1928. TOUCHEVENTF_PRIMARY = 0x0010,
  1929. /// <summary>
  1930. /// When received using GetTouchInputInfo, this input was not coalesced.
  1931. /// </summary>
  1932. TOUCHEVENTF_NOCOALESCE = 0x0020,
  1933. /// <summary>
  1934. /// The touch event came from the user's palm.
  1935. /// </summary>
  1936. TOUCHEVENTF_PALM = 0x0080
  1937. }
  1938. [Flags]
  1939. public enum OpenFileNameFlags
  1940. {
  1941. OFN_ALLOWMULTISELECT = 0x00000200,
  1942. OFN_EXPLORER = 0x00080000,
  1943. OFN_HIDEREADONLY = 0x00000004,
  1944. OFN_NOREADONLYRETURN = 0x00008000,
  1945. OFN_OVERWRITEPROMPT = 0x00000002
  1946. }
  1947. public enum HRESULT : uint
  1948. {
  1949. S_FALSE = 0x0001,
  1950. S_OK = 0x0000,
  1951. E_INVALIDARG = 0x80070057,
  1952. E_OUTOFMEMORY = 0x8007000E,
  1953. E_NOTIMPL = 0x80004001,
  1954. E_UNEXPECTED = 0x8000FFFF,
  1955. E_CANCELLED = 0x800704C7,
  1956. }
  1957. public enum Icons
  1958. {
  1959. ICON_SMALL = 0,
  1960. ICON_BIG = 1
  1961. }
  1962. public static class ShellIds
  1963. {
  1964. public static readonly Guid OpenFileDialog = Guid.Parse("DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7");
  1965. public static readonly Guid SaveFileDialog = Guid.Parse("C0B4E2F3-BA21-4773-8DBA-335EC946EB8B");
  1966. public static readonly Guid IFileDialog = Guid.Parse("42F85136-DB7E-439C-85F1-E4075D135FC8");
  1967. public static readonly Guid IShellItem = Guid.Parse("43826D1E-E718-42EE-BC55-A1E261C37BFE");
  1968. public static readonly Guid TaskBarList = Guid.Parse("56FDF344-FD6D-11D0-958A-006097C9A090");
  1969. public static readonly Guid ITaskBarList2 = Guid.Parse("ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf");
  1970. }
  1971. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
  1972. public struct COMDLG_FILTERSPEC
  1973. {
  1974. [MarshalAs(UnmanagedType.LPWStr)]
  1975. public string pszName;
  1976. [MarshalAs(UnmanagedType.LPWStr)]
  1977. public string pszSpec;
  1978. }
  1979. public delegate void MarkFullscreenWindow(IntPtr This, IntPtr hwnd, [MarshalAs(UnmanagedType.Bool)] bool fullscreen);
  1980. public delegate HRESULT HrInit(IntPtr This);
  1981. public struct ITaskBarList2VTable
  1982. {
  1983. public IntPtr IUnknown1;
  1984. public IntPtr IUnknown2;
  1985. public IntPtr IUnknown3;
  1986. public IntPtr HrInit;
  1987. public IntPtr AddTab;
  1988. public IntPtr DeleteTab;
  1989. public IntPtr ActivateTab;
  1990. public IntPtr SetActiveAlt;
  1991. public IntPtr MarkFullscreenWindow;
  1992. }
  1993. }
  1994. [StructLayoutAttribute(LayoutKind.Sequential)]
  1995. internal struct _DROPFILES
  1996. {
  1997. public Int32 pFiles;
  1998. public Int32 X;
  1999. public Int32 Y;
  2000. public bool fNC;
  2001. public bool fWide;
  2002. }
  2003. [StructLayoutAttribute(LayoutKind.Sequential)]
  2004. internal struct STGMEDIUM
  2005. {
  2006. public TYMED tymed;
  2007. public IntPtr unionmember;
  2008. public IntPtr pUnkForRelease;
  2009. }
  2010. [StructLayoutAttribute(LayoutKind.Sequential)]
  2011. internal struct FORMATETC
  2012. {
  2013. public ushort cfFormat;
  2014. public IntPtr ptd;
  2015. public DVASPECT dwAspect;
  2016. public int lindex;
  2017. public TYMED tymed;
  2018. }
  2019. [Flags]
  2020. internal enum PixelFormatDescriptorFlags : uint
  2021. {
  2022. PFD_DOUBLEBUFFER = 0x00000001,
  2023. PFD_STEREO = 0x00000002,
  2024. PFD_DRAW_TO_WINDOW = 0x00000004,
  2025. PFD_DRAW_TO_BITMAP = 0x00000008,
  2026. PFD_SUPPORT_GDI = 0x00000010,
  2027. PFD_SUPPORT_OPENGL = 0x00000020,
  2028. PFD_GENERIC_FORMAT = 0x00000040,
  2029. PFD_NEED_PALETTE = 0x00000080,
  2030. PFD_NEED_SYSTEM_PALETTE = 0x00000100,
  2031. PFD_SWAP_EXCHANGE = 0x00000200,
  2032. PFD_SWAP_COPY = 0x00000400,
  2033. PFD_SWAP_LAYER_BUFFERS = 0x00000800,
  2034. PFD_GENERIC_ACCELERATED = 0x00001000,
  2035. PFD_SUPPORT_DIRECTDRAW = 0x00002000,
  2036. PFD_DEPTH_DONTCARE = 0x20000000,
  2037. PFD_DOUBLEBUFFER_DONTCARE = 0x40000000,
  2038. PFD_STEREO_DONTCARE = 0x80000000,
  2039. }
  2040. [StructLayout(LayoutKind.Sequential)]
  2041. internal struct PixelFormatDescriptor
  2042. {
  2043. public ushort Size;
  2044. public ushort Version;
  2045. public PixelFormatDescriptorFlags Flags;
  2046. public byte PixelType;
  2047. public byte ColorBits;
  2048. public byte RedBits;
  2049. public byte RedShift;
  2050. public byte GreenBits;
  2051. public byte GreenShift;
  2052. public byte BlueBits;
  2053. public byte BlueShift;
  2054. public byte AlphaBits;
  2055. public byte AlphaShift;
  2056. public byte AccumBits;
  2057. public byte AccumRedBits;
  2058. public byte AccumGreenBits;
  2059. public byte AccumBlueBits;
  2060. public byte AccumAlphaBits;
  2061. public byte DepthBits;
  2062. public byte StencilBits;
  2063. public byte AuxBuffers;
  2064. public byte LayerType;
  2065. private byte Reserved;
  2066. public uint LayerMask;
  2067. public uint VisibleMask;
  2068. public uint DamageMask;
  2069. }
  2070. internal enum NIM : uint
  2071. {
  2072. ADD = 0x00000000,
  2073. MODIFY = 0x00000001,
  2074. DELETE = 0x00000002,
  2075. SETFOCUS = 0x00000003,
  2076. SETVERSION = 0x00000004
  2077. }
  2078. [Flags]
  2079. internal enum NIF : uint
  2080. {
  2081. MESSAGE = 0x00000001,
  2082. ICON = 0x00000002,
  2083. TIP = 0x00000004,
  2084. STATE = 0x00000008,
  2085. INFO = 0x00000010,
  2086. GUID = 0x00000020,
  2087. REALTIME = 0x00000040,
  2088. SHOWTIP = 0x00000080
  2089. }
  2090. [Flags]
  2091. internal enum NIIF : uint
  2092. {
  2093. NONE = 0x00000000,
  2094. INFO = 0x00000001,
  2095. WARNING = 0x00000002,
  2096. ERROR = 0x00000003,
  2097. USER = 0x00000004,
  2098. ICON_MASK = 0x0000000F,
  2099. NOSOUND = 0x00000010,
  2100. LARGE_ICON = 0x00000020,
  2101. RESPECT_QUIET_TIME = 0x00000080
  2102. }
  2103. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
  2104. internal class NOTIFYICONDATA
  2105. {
  2106. public int cbSize = Marshal.SizeOf<NOTIFYICONDATA>();
  2107. public IntPtr hWnd;
  2108. public int uID;
  2109. public NIF uFlags;
  2110. public int uCallbackMessage;
  2111. public IntPtr hIcon;
  2112. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
  2113. public string szTip;
  2114. public int dwState = 0;
  2115. public int dwStateMask = 0;
  2116. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
  2117. public string szInfo;
  2118. public int uTimeoutOrVersion;
  2119. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
  2120. public string szInfoTitle;
  2121. public NIIF dwInfoFlags;
  2122. }
  2123. }