uxtheme.pp 95 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998
  1. {******************************************************************************}
  2. { }
  3. { Visual Styles (Themes) API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: uxtheme.h, released June 2001. The original Pascal }
  9. { code is: UxTheme.pas, released July 2001. The initial developer of the }
  10. { Pascal code is Marcel van Brakel ([email protected]). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Portions created by Mike Lischke are Copyright (C) 1999-2002 }
  16. { Mike Lischke. All Rights Reserved. }
  17. { }
  18. { Potions created by Paul Ishenin are Copyright (C) 2009 }
  19. { Paul Ishenin. All Rights Reserved }
  20. { }
  21. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  22. { }
  23. { You may retrieve the latest version of this file at the Project JEDI home }
  24. { page, located at http://delphi-jedi.org or my personal homepage located at }
  25. { http://members.chello.nl/m.vanbrakel2 }
  26. { }
  27. { The contents of this file are used with permission, subject to the Mozilla }
  28. { Public License Version 1.1 (the "License"); you may not use this file except }
  29. { in compliance with the License. You may obtain a copy of the License at }
  30. { http://www.mozilla.org/MPL/MPL-1.1.html }
  31. { }
  32. { Software distributed under the License is distributed on an "AS IS" basis, }
  33. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  34. { the specific language governing rights and limitations under the License. }
  35. { }
  36. { Alternatively, the contents of this file may be used under the terms }
  37. { specified in the COPYING.FPC file in this distribution }
  38. { }
  39. {******************************************************************************}
  40. {$IFNDEF FPC_DOTTEDUNITS}
  41. unit UxTheme;
  42. {$ENDIF FPC_DOTTEDUNITS}
  43. {$mode objfpc}{$H+}
  44. {$HPPEMIT ''}
  45. {$HPPEMIT '#include "uxtheme.h"'}
  46. {$HPPEMIT ''}
  47. interface
  48. {$IFDEF FPC_DOTTEDUNITS}
  49. uses
  50. WinApi.Windows;
  51. {$ELSE FPC_DOTTEDUNITS}
  52. uses
  53. Windows;
  54. {$ENDIF FPC_DOTTEDUNITS}
  55. // this file is in uxtheme under Delphi, while a separate one in apilib
  56. {$i tmschema.inc}
  57. procedure FreeThemeLibrary;
  58. function InitThemeLibrary: Boolean;
  59. function UseThemes: Boolean;
  60. const
  61. WM_THEMECHANGED = $031A;
  62. type
  63. HTHEME = THANDLE; // handle to a section of theme data for class
  64. {$EXTERNALSYM HTHEME}
  65. const
  66. //if (_WIN32_WINNT >= 0x0600)
  67. MAX_THEMECOLOR = 64;
  68. {$EXTERNALSYM MAX_THEMECOLOR}
  69. MAX_THEMESIZE = 64;
  70. {$EXTERNALSYM MAX_THEMESIZE}
  71. //endif
  72. //if (NTDDI_VERSION>= NTDDI_WIN7)
  73. //---------------------------------------------------------------------------
  74. // BeginPanningFeedback - Visual feedback init function related to pan gesture
  75. // - internally called by DefaultGestureHandler
  76. // - called by application
  77. //
  78. // HWND hwnd - The handle to the Target window that will receive feedback
  79. //
  80. //---------------------------------------------------------------------------
  81. var
  82. BeginPanningFeedback: function(hwnd: HWND): BOOL; stdcall;
  83. {$EXTERNALSYM BeginPanningFeedback}
  84. //---------------------------------------------------------------------------
  85. // UpdatePanningFeedback : Visual feedback function related to pan gesture
  86. // Can Be called only after a BeginPanningFeedback call
  87. // - internally called by DefaultGestureHandler
  88. // - called by application
  89. //
  90. // HWND hwnd - The handle to the Target window that will receive feedback
  91. // For the method to succeed this must be the same hwnd as provided in
  92. // BeginPanningFeedback
  93. //
  94. // LONG lTotalOverpanOffsetX - The Total displacement that the window has moved in the horizontal direction
  95. // since the end of scrollable region was reached. The API would move the window by the distance specified
  96. // A maximum displacement of 30 pixels is allowed
  97. //
  98. // LONG lTotalOverpanOffsetY - The Total displacement that the window has moved in the horizontal direction
  99. // since the end of scrollable
  100. // region was reached. The API would move the window by the distance specified
  101. // A maximum displacement of 30 pixels is allowed
  102. //
  103. // BOOL fInInertia - Flag dictating whether the Application is handling a WM_GESTURE message with the
  104. // GF_INERTIA FLAG set
  105. //
  106. // Incremental calls to UpdatePanningFeedback should make sure they always pass
  107. // the sum of the increments and not just the increment themselves
  108. // Eg : If the initial displacement is 10 pixels and the next displacement 10 pixels
  109. // the second call would be with the parameter as 20 pixels as opposed to 10
  110. // Eg : UpdatePanningFeedback(hwnd, 10, 10, TRUE)
  111. //
  112. var
  113. UpdatePanningFeedback: function(hwnd: HWND; lTotalOverpanOffsetX: LONG; lTotalOverpanOffsetY: LONG;
  114. fInInertia: BOOL): BOOL; stdcall;
  115. {$EXTERNALSYM UpdatePanningFeedback}
  116. //---------------------------------------------------------------------------
  117. //
  118. // EndPanningFeedback :Visual feedback reset function related to pan gesture
  119. // - internally called by DefaultGestureHandler
  120. // - called by application
  121. // Terminates any existing animation that was in process or set up by BeginPanningFeedback and UpdatePanningFeedback
  122. // The EndPanningFeedBack needs to be called Prior to calling any BeginPanningFeedBack if we have already
  123. // called a BeginPanningFeedBack followed by one/ more UpdatePanningFeedback calls
  124. //
  125. // HWND hwnd - The handle to the Target window that will receive feedback
  126. //
  127. // BOOL fAnimateBack - Flag to indicate whether you wish the displaced window to move back
  128. // to the original position via animation or a direct jump.
  129. // Either ways the method will try to restore the moved window.
  130. // The latter case exists for compatibility with legacy apps.
  131. //
  132. var
  133. EndPanningFeedback: function(hwnd: HWND; fAnimateBack: BOOL): BOOL; stdcall;
  134. {$EXTERNALSYM EndPanningFeedback}
  135. //endif
  136. //----------------------------------------------------------------------------------------------------------------------
  137. // NOTE: PartId's and StateId's used in the theme API are defined in the
  138. // hdr file <tmschema.h> using the TM_PART and TM_STATE macros. For
  139. // example, "TM_PART(BP, PUSHBUTTON)" defines the PartId "BP_PUSHBUTTON".
  140. //----------------------------------------------------------------------------------------------------------------------
  141. // OpenThemeData() - Open the theme data for the specified HWND and
  142. // semi-colon separated list of class names.
  143. //
  144. // OpenThemeData() will try each class name, one at
  145. // a time, and use the first matching theme info
  146. // found. If a match is found, a theme handle
  147. // to the data is returned. If no match is found,
  148. // a "NULL" handle is returned.
  149. //
  150. // When the window is destroyed or a WM_THEMECHANGED
  151. // msg is received, "CloseThemeData()" should be
  152. // called to close the theme handle.
  153. //
  154. // hwnd - window handle of the control/window to be themed
  155. //
  156. // pszClassList - class name (or list of names) to match to theme data
  157. // section. if the list contains more than one name,
  158. // the names are tested one at a time for a match.
  159. // If a match is found, OpenThemeData() returns a
  160. // theme handle associated with the matching class.
  161. // This param is a list (instead of just a single
  162. // class name) to provide the class an opportunity
  163. // to get the "best" match between the class and
  164. // the current theme. For example, a button might
  165. // pass L"OkButton, Button" if its ID=ID_OK. If
  166. // the current theme has an entry for OkButton,
  167. // that will be used. Otherwise, we fall back on
  168. // the normal Button entry.
  169. //----------------------------------------------------------------------------------------------------------------------
  170. var
  171. OpenThemeData: function(hwnd: HWND; pszClassList: LPCWSTR): HTHEME; stdcall;
  172. {$EXTERNALSYM OpenThemeData}
  173. const
  174. OTD_FORCE_RECT_SIZING = $00000001; // make all parts size to rect
  175. {$EXTERNALSYM OTD_FORCE_RECT_SIZING}
  176. OTD_NONCLIENT = $00000002; // set if hTheme to be used for nonclient area
  177. {$EXTERNALSYM OTD_NONCLIENT}
  178. OTD_VALIDBITS = (OTD_FORCE_RECT_SIZING or OTD_NONCLIENT);
  179. {$EXTERNALSYM OTD_VALIDBITS}
  180. //---------------------------------------------------------------------------
  181. // OpenThemeDataEx - Open the theme data for the specified HWND and
  182. // semi-colon separated list of class names.
  183. //
  184. // OpenThemeData() will try each class name, one at
  185. // a time, and use the first matching theme info
  186. // found. If a match is found, a theme handle
  187. // to the data is returned. If no match is found,
  188. // a "NULL" handle is returned.
  189. //
  190. // When the window is destroyed or a WM_THEMECHANGED
  191. // msg is received, "CloseThemeData()" should be
  192. // called to close the theme handle.
  193. //
  194. // hwnd - window handle of the control/window to be themed
  195. //
  196. // pszClassList - class name (or list of names) to match to theme data
  197. // section. if the list contains more than one name,
  198. // the names are tested one at a time for a match.
  199. // If a match is found, OpenThemeData() returns a
  200. // theme handle associated with the matching class.
  201. // This param is a list (instead of just a single
  202. // class name) to provide the class an opportunity
  203. // to get the "best" match between the class and
  204. // the current theme. For example, a button might
  205. // pass L"OkButton, Button" if its ID=ID_OK. If
  206. // the current theme has an entry for OkButton,
  207. // that will be used. Otherwise, we fall back on
  208. // the normal Button entry.
  209. //
  210. // dwFlags - allows certain overrides of std features
  211. // (see OTD_XXX defines above)
  212. //---------------------------------------------------------------------------
  213. var
  214. OpenThemeDataEx: function(hwnd: HWND; pszClassList: LPCWSTR; dwFlags: DWORD): HTHEME; stdcall;
  215. {$EXTERNALSYM OpenThemeDataEx}
  216. //----------------------------------------------------------------------------------------------------------------------
  217. // CloseTHemeData() - closes the theme data handle. This should be done
  218. // when the window being themed is destroyed or
  219. // whenever a WM_THEMECHANGED msg is received
  220. // (followed by an attempt to create a new Theme data
  221. // handle).
  222. //
  223. // hTheme - open theme data handle (returned from prior call
  224. // to OpenThemeData() API).
  225. //----------------------------------------------------------------------------------------------------------------------
  226. var
  227. CloseThemeData: function(hTheme: HTHEME): HRESULT; stdcall;
  228. {$EXTERNALSYM CloseThemeData}
  229. //----------------------------------------------------------------------------------------------------------------------
  230. // functions for basic drawing support
  231. //----------------------------------------------------------------------------------------------------------------------
  232. // The following methods are the theme-aware drawing services.
  233. // Controls/Windows are defined in drawable "parts" by their author: a
  234. // parent part and 0 or more child parts. Each of the parts can be
  235. // described in "states" (ex: disabled, hot, pressed).
  236. //----------------------------------------------------------------------------------------------------------------------
  237. // For the list of all themed classes and the definition of all
  238. // parts and states, see the file "tmschmea.h".
  239. //----------------------------------------------------------------------------------------------------------------------
  240. // Each of the below methods takes a "iPartId" param to specify the
  241. // part and a "iStateId" to specify the state of the part.
  242. // "iStateId=0" refers to the root part. "iPartId" = "0" refers to
  243. // the root class.
  244. //----------------------------------------------------------------------------------------------------------------------
  245. // Note: draw operations are always scaled to fit (and not to exceed)
  246. // the specified "Rect".
  247. //----------------------------------------------------------------------------------------------------------------------
  248. //----------------------------------------------------------------------------------------------------------------------
  249. // DrawThemeBackground()
  250. // - draws the theme-specified border and fill for
  251. // the "iPartId" and "iStateId". This could be
  252. // based on a bitmap file, a border and fill, or
  253. // other image description.
  254. //
  255. // hTheme - theme data handle
  256. // hdc - HDC to draw into
  257. // iPartId - part number to draw
  258. // iStateId - state number (of the part) to draw
  259. // pRect - defines the size/location of the part
  260. // pClipRect - optional clipping rect (don't draw outside it)
  261. //----------------------------------------------------------------------------------------------------------------------
  262. var
  263. DrawThemeBackground: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer; const pRect: TRect;
  264. pClipRect: PRECT): HRESULT; stdcall;
  265. {$EXTERNALSYM DrawThemeBackground}
  266. //------------------------------------------------------------------------
  267. //---- bits used in dwFlags of DTBGOPTS ----
  268. const
  269. DTBG_CLIPRECT = $00000001; // rcClip has been specified
  270. {$EXTERNALSYM DTBG_CLIPRECT}
  271. DTBG_DRAWSOLID = $00000002; // DEPRECATED: draw transparent/alpha images as solid
  272. {$EXTERNALSYM DTBG_DRAWSOLID}
  273. DTBG_OMITBORDER = $00000004; // don't draw border of part
  274. {$EXTERNALSYM DTBG_OMITBORDER}
  275. DTBG_OMITCONTENT = $00000008; // don't draw content area of part
  276. {$EXTERNALSYM DTBG_OMITCONTENT}
  277. DTBG_COMPUTINGREGION = $00000010; // TRUE if calling to compute region
  278. {$EXTERNALSYM DTBG_COMPUTINGREGION}
  279. DTBG_MIRRORDC = $00000020; // assume the hdc is mirrorred and
  280. // flip images as appropriate (currently
  281. // only supported for bgtype=imagefile)
  282. {$EXTERNALSYM DTBG_MIRRORDC}
  283. DTBG_NOMIRROR = $00000040; // don't mirror the output, overrides everything else
  284. {$EXTERNALSYM DTBG_NOMIRROR}
  285. DTBG_VALIDBITS = (DTBG_CLIPRECT or
  286. DTBG_DRAWSOLID or
  287. DTBG_OMITBORDER or
  288. DTBG_OMITCONTENT or
  289. DTBG_COMPUTINGREGION or
  290. DTBG_MIRRORDC or
  291. DTBG_NOMIRROR);
  292. {$EXTERNALSYM DTBG_VALIDBITS}
  293. type
  294. _DTBGOPTS = record
  295. dwSize: DWORD; // size of the struct
  296. dwFlags: DWORD; // which options have been specified
  297. rcClip: TRect; // clipping rectangle
  298. end;
  299. {$EXTERNALSYM _DTBGOPTS}
  300. DTBGOPTS = _DTBGOPTS;
  301. {$EXTERNALSYM DTBGOPTS}
  302. PDTBGOPTS = ^_DTBGOPTS;
  303. {$EXTERNALSYM PDTBGOPTS}
  304. TDTBgOpts = DTBGOPTS;
  305. //------------------------------------------------------------------------
  306. // DrawThemeBackgroundEx()
  307. // - draws the theme-specified border and fill for
  308. // the "iPartId" and "iStateId". This could be
  309. // based on a bitmap file, a border and fill, or
  310. // other image description. NOTE: This will be
  311. // merged back into DrawThemeBackground() after
  312. // BETA 2.
  313. //
  314. // hTheme - theme data handle
  315. // hdc - HDC to draw into
  316. // iPartId - part number to draw
  317. // iStateId - state number (of the part) to draw
  318. // pRect - defines the size/location of the part
  319. // pOptions - ptr to optional params
  320. //------------------------------------------------------------------------
  321. var
  322. DrawThemeBackgroundEx: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer; const pRect: TRect;
  323. pOptions: PDTBGOPTS): HRESULT; stdcall;
  324. {$EXTERNALSYM DrawThemeBackgroundEx}
  325. //----------------------------------------------------------------------------------------------------------------------
  326. //----- DrawThemeText() flags ----
  327. const
  328. DTT_GRAYED = $1; // draw a grayed-out string
  329. {$EXTERNALSYM DTT_GRAYED}
  330. //----------------------------------------------------------------------------------------------------------------------
  331. // DrawThemeText() - draws the text using the theme-specified
  332. // color and font for the "iPartId" and
  333. // "iStateId".
  334. //
  335. // hTheme - theme data handle
  336. // hdc - HDC to draw into
  337. // iPartId - part number to draw
  338. // iStateId - state number (of the part) to draw
  339. // pszText - actual text to draw
  340. // dwCharCount - number of chars to draw (-1 for all)
  341. // dwTextFlags - same as DrawText() "uFormat" param
  342. // dwTextFlags2 - additional drawing options
  343. // pRect - defines the size/location of the part
  344. //----------------------------------------------------------------------------------------------------------------------
  345. var
  346. DrawThemeText: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer; pszText: LPCWSTR; iCharCount: Integer;
  347. dwTextFlags, dwTextFlags2: DWORD; const pRect: TRect): HRESULT; stdcall;
  348. {$EXTERNALSYM DrawThemeText}
  349. //----------------------------------------------------------------------------------------------------------------------
  350. // GetThemeBackgroundContentRect()
  351. // - gets the size of the content for the theme-defined
  352. // background. This is usually the area inside
  353. // the borders or Margins.
  354. //
  355. // hTheme - theme data handle
  356. // hdc - (optional) device content to be used for drawing
  357. // iPartId - part number to draw
  358. // iStateId - state number (of the part) to draw
  359. // pBoundingRect - the outer RECT of the part being drawn
  360. // pContentRect - RECT to receive the content area
  361. //----------------------------------------------------------------------------------------------------------------------
  362. var
  363. GetThemeBackgroundContentRect: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer;
  364. const pBoundingRect: TRect; pContentRect: PRECT): HRESULT; stdcall;
  365. {$EXTERNALSYM GetThemeBackgroundContentRect}
  366. //----------------------------------------------------------------------------------------------------------------------
  367. // GetThemeBackgroundExtent() - calculates the size/location of the theme-
  368. // specified background based on the
  369. // "pContentRect".
  370. //
  371. // hTheme - theme data handle
  372. // hdc - (optional) device content to be used for drawing
  373. // iPartId - part number to draw
  374. // iStateId - state number (of the part) to draw
  375. // pContentRect - RECT that defines the content area
  376. // pBoundingRect - RECT to receive the overall size/location of part
  377. //----------------------------------------------------------------------------------------------------------------------
  378. var
  379. GetThemeBackgroundExtent: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer; const pContentRect: TRect;
  380. var pExtentRect: TRect): HRESULT; stdcall;
  381. {$EXTERNALSYM GetThemeBackgroundExtent}
  382. //----------------------------------------------------------------------------------------------------------------------
  383. // GetThemeBackgroundRegion()
  384. // - computes the region for a regular or partially
  385. // transparent theme-specified background that is
  386. // bound by the specified "pRect".
  387. // If the rectangle is empty, sets the HRGN to NULL
  388. // and return S_FALSE.
  389. //
  390. // hTheme - theme data handle
  391. // hdc - optional HDC to draw into (DPI scaling)
  392. // iPartId - part number to draw
  393. // iStateId - state number (of the part)
  394. // pRect - the RECT used to draw the part
  395. // pRegion - receives handle to calculated region
  396. //----------------------------------------------------------------------------------------------------------------------
  397. var
  398. GetThemeBackgroundRegion: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer; const pRect: TRect;
  399. var pRegion: HRGN): HRESULT; stdcall;
  400. {$EXTERNALSYM GetThemeBackgroundRegion}
  401. //----------------------------------------------------------------------------------------------------------------------
  402. type
  403. THEMESIZE = (
  404. TS_MIN, // minimum size
  405. TS_TRUE, // size without stretching
  406. TS_DRAW // size that theme mgr will use to draw part
  407. );
  408. {$EXTERNALSYM THEMESIZE}
  409. TThemeSize = THEMESIZE;
  410. //----------------------------------------------------------------------------------------------------------------------
  411. // GetThemePartSize() - returns the specified size of the theme part
  412. //
  413. // hTheme - theme data handle
  414. // hdc - HDC to select font into & measure against
  415. // iPartId - part number to retrieve size for
  416. // iStateId - state number (of the part)
  417. // prc - (optional) rect for part drawing destination
  418. // eSize - the type of size to be retreived
  419. // psz - receives the specified size of the part
  420. //----------------------------------------------------------------------------------------------------------------------
  421. var
  422. GetThemePartSize: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer; prc: PRECT; eSize: THEMESIZE;
  423. var psz: TSize): HRESULT; stdcall;
  424. {$EXTERNALSYM GetThemePartSize}
  425. //----------------------------------------------------------------------------------------------------------------------
  426. // GetThemeTextExtent() - calculates the size/location of the specified
  427. // text when rendered in the Theme Font.
  428. //
  429. // hTheme - theme data handle
  430. // hdc - HDC to select font & measure into
  431. // iPartId - part number to draw
  432. // iStateId - state number (of the part)
  433. // pszText - the text to be measured
  434. // dwCharCount - number of chars to draw (-1 for all)
  435. // dwTextFlags - same as DrawText() "uFormat" param
  436. // pszBoundingRect - optional: to control layout of text
  437. // pszExtentRect - receives the RECT for text size/location
  438. //----------------------------------------------------------------------------------------------------------------------
  439. var
  440. GetThemeTextExtent: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer; pszText: LPCWSTR;
  441. iCharCount: Integer; dwTextFlags: DWORD; pBoundingRect: PRECT; var pExtentRect: TRect): HRESULT; stdcall;
  442. {$EXTERNALSYM GetThemeTextExtent}
  443. //----------------------------------------------------------------------------------------------------------------------
  444. // GetThemeTextMetrics()
  445. // - returns info about the theme-specified font
  446. // for the part/state passed in.
  447. //
  448. // hTheme - theme data handle
  449. // hdc - optional: HDC for screen context
  450. // iPartId - part number to draw
  451. // iStateId - state number (of the part)
  452. // ptm - receives the font info
  453. //----------------------------------------------------------------------------------------------------------------------
  454. var
  455. GetThemeTextMetrics: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer;
  456. var ptm: TEXTMETRIC): HRESULT; stdcall;
  457. {$EXTERNALSYM GetThemeTextMetrics}
  458. //----------------------------------------------------------------------------------------------------------------------
  459. //----- HitTestThemeBackground, HitTestThemeBackgroundRegion flags ----
  460. // Theme background segment hit test flag (default). possible return values are:
  461. // HTCLIENT: hit test succeeded in the middle background segment
  462. // HTTOP, HTLEFT, HTTOPLEFT, etc: // hit test succeeded in the the respective theme background segment.
  463. const
  464. HTTB_BACKGROUNDSEG = $0000;
  465. {$EXTERNALSYM HTTB_BACKGROUNDSEG}
  466. // Fixed border hit test option. possible return values are:
  467. // HTCLIENT: hit test succeeded in the middle background segment
  468. // HTBORDER: hit test succeeded in any other background segment
  469. HTTB_FIXEDBORDER = $0002; // Return code may be either HTCLIENT or HTBORDER.
  470. {$EXTERNALSYM HTTB_FIXEDBORDER}
  471. // Caption hit test option. Possible return values are:
  472. // HTCAPTION: hit test succeeded in the top, top left, or top right background segments
  473. // HTNOWHERE or another return code, depending on absence or presence of accompanying flags, resp.
  474. HTTB_CAPTION = $0004;
  475. {$EXTERNALSYM HTTB_CAPTION}
  476. // Resizing border hit test flags. Possible return values are:
  477. // HTCLIENT: hit test succeeded in middle background segment
  478. // HTTOP, HTTOPLEFT, HTLEFT, HTRIGHT, etc: hit test succeeded in the respective system resizing zone
  479. // HTBORDER: hit test failed in middle segment and resizing zones, but succeeded in a background border segment
  480. HTTB_RESIZINGBORDER_LEFT = $0010; // Hit test left resizing border,
  481. {$EXTERNALSYM HTTB_RESIZINGBORDER_LEFT}
  482. HTTB_RESIZINGBORDER_TOP = $0020; // Hit test top resizing border
  483. {$EXTERNALSYM HTTB_RESIZINGBORDER_TOP}
  484. HTTB_RESIZINGBORDER_RIGHT = $0040; // Hit test right resizing border
  485. {$EXTERNALSYM HTTB_RESIZINGBORDER_RIGHT}
  486. HTTB_RESIZINGBORDER_BOTTOM = $0080; // Hit test bottom resizing border
  487. {$EXTERNALSYM HTTB_RESIZINGBORDER_BOTTOM}
  488. HTTB_RESIZINGBORDER = (HTTB_RESIZINGBORDER_LEFT or HTTB_RESIZINGBORDER_TOP or
  489. HTTB_RESIZINGBORDER_RIGHT or HTTB_RESIZINGBORDER_BOTTOM);
  490. {$EXTERNALSYM HTTB_RESIZINGBORDER}
  491. // Resizing border is specified as a template, not just window edges.
  492. // This option is mutually exclusive with HTTB_SYSTEMSIZINGWIDTH; HTTB_SIZINGTEMPLATE takes precedence
  493. HTTB_SIZINGTEMPLATE = $0100;
  494. {$EXTERNALSYM HTTB_SIZINGTEMPLATE}
  495. // Use system resizing border width rather than theme content margins.
  496. // This option is mutually exclusive with HTTB_SIZINGTEMPLATE, which takes precedence.
  497. HTTB_SYSTEMSIZINGMARGINS = $0200;
  498. {$EXTERNALSYM HTTB_SYSTEMSIZINGMARGINS}
  499. //----------------------------------------------------------------------------------------------------------------------
  500. // HitTestThemeBackground()
  501. // - returns a HitTestCode (a subset of the values
  502. // returned by WM_NCHITTEST) for the point "ptTest"
  503. // within the theme-specified background
  504. // (bound by pRect). "pRect" and "ptTest" should
  505. // both be in the same coordinate system
  506. // (client, screen, etc).
  507. //
  508. // hTheme - theme data handle
  509. // hdc - HDC to draw into
  510. // iPartId - part number to test against
  511. // iStateId - state number (of the part)
  512. // pRect - the RECT used to draw the part
  513. // hrgn - optional region to use; must be in same coordinates as
  514. // - pRect and pTest.
  515. // ptTest - the hit point to be tested
  516. // dwOptions - HTTB_xxx constants
  517. // pwHitTestCode - receives the returned hit test code - one of:
  518. //
  519. // HTNOWHERE, HTLEFT, HTTOPLEFT, HTBOTTOMLEFT,
  520. // HTRIGHT, HTTOPRIGHT, HTBOTTOMRIGHT,
  521. // HTTOP, HTBOTTOM, HTCLIENT
  522. //----------------------------------------------------------------------------------------------------------------------
  523. var
  524. HitTestThemeBackground: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer; dwOptions: DWORD;
  525. const pRect: TRect; hrgn: HRGN; ptTest: TPoint; var pwHitTestCode: WORD): HRESULT; stdcall;
  526. {$EXTERNALSYM HitTestThemeBackground}
  527. //----------------------------------------------------------------------------------------------------------------------
  528. // DrawThemeEdge() - Similar to the DrawEdge() API, but uses part colors
  529. // and is high-DPI aware
  530. // hTheme - theme data handle
  531. // hdc - HDC to draw into
  532. // iPartId - part number to draw
  533. // iStateId - state number of part
  534. // pDestRect - the RECT used to draw the line(s)
  535. // uEdge - Same as DrawEdge() API
  536. // uFlags - Same as DrawEdge() API
  537. // pContentRect - Receives the interior rect if (uFlags & BF_ADJUST)
  538. //----------------------------------------------------------------------------------------------------------------------
  539. var
  540. DrawThemeEdge: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer; const pDestRect: TRect; uEdge,
  541. uFlags: UINT; pContentRect: PRECT): HRESULT; stdcall;
  542. {$EXTERNALSYM DrawThemeEdge}
  543. //----------------------------------------------------------------------------------------------------------------------
  544. // DrawThemeIcon() - draws an image within an imagelist based on
  545. // a (possible) theme-defined effect.
  546. //
  547. // hTheme - theme data handle
  548. // hdc - HDC to draw into
  549. // iPartId - part number to draw
  550. // iStateId - state number of part
  551. // pRect - the RECT to draw the image within
  552. // himl - handle to IMAGELIST
  553. // iImageIndex - index into IMAGELIST (which icon to draw)
  554. //----------------------------------------------------------------------------------------------------------------------
  555. var
  556. DrawThemeIcon: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer; const pRect: TRect; himl: HIMAGELIST;
  557. iImageIndex: Integer): HRESULT; stdcall;
  558. {$EXTERNALSYM DrawThemeIcon}
  559. //----------------------------------------------------------------------------------------------------------------------
  560. // IsThemePartDefined() - returns TRUE if the theme has defined parameters
  561. // for the specified "iPartId" and "iStateId".
  562. //
  563. // hTheme - theme data handle
  564. // iPartId - part number to find definition for
  565. // iStateId - state number of part
  566. //----------------------------------------------------------------------------------------------------------------------
  567. var
  568. IsThemePartDefined: function(hTheme: HTHEME; iPartId, iStateId: Integer): BOOL; stdcall;
  569. {$EXTERNALSYM IsThemePartDefined}
  570. //----------------------------------------------------------------------------------------------------------------------
  571. // IsThemeBackgroundPartiallyTransparent()
  572. // - returns TRUE if the theme specified background for
  573. // the part/state has transparent pieces or
  574. // alpha-blended pieces.
  575. //
  576. // hTheme - theme data handle
  577. // iPartId - part number
  578. // iStateId - state number of part
  579. //----------------------------------------------------------------------------------------------------------------------
  580. var
  581. IsThemeBackgroundPartiallyTransparent: function(hTheme: HTHEME; iPartId, iStateId: Integer): BOOL; stdcall;
  582. {$EXTERNALSYM IsThemeBackgroundPartiallyTransparent}
  583. //----------------------------------------------------------------------------------------------------------------------
  584. // lower-level theme information services
  585. //----------------------------------------------------------------------------------------------------------------------
  586. // The following methods are getter routines for each of the Theme Data types.
  587. // Controls/Windows are defined in drawable "parts" by their author: a
  588. // parent part and 0 or more child parts. Each of the parts can be
  589. // described in "states" (ex: disabled, hot, pressed).
  590. //----------------------------------------------------------------------------------------------------------------------
  591. // Each of the below methods takes a "iPartId" param to specify the
  592. // part and a "iStateId" to specify the state of the part.
  593. // "iStateId=0" refers to the root part. "iPartId" = "0" refers to
  594. // the root class.
  595. //----------------------------------------------------------------------------------------------------------------------
  596. // Each method also take a "iPropId" param because multiple instances of
  597. // the same primitive type can be defined in the theme schema.
  598. //----------------------------------------------------------------------------------------------------------------------
  599. //----------------------------------------------------------------------------------------------------------------------
  600. // GetThemeColor() - Get the value for the specified COLOR property
  601. //
  602. // hTheme - theme data handle
  603. // iPartId - part number
  604. // iStateId - state number of part
  605. // iPropId - the property number to get the value for
  606. // pColor - receives the value of the property
  607. //----------------------------------------------------------------------------------------------------------------------
  608. var
  609. GetThemeColor: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer; var pColor: COLORREF): HRESULT; stdcall;
  610. {$EXTERNALSYM GetThemeColor}
  611. //----------------------------------------------------------------------------------------------------------------------
  612. // GetThemeMetric() - Get the value for the specified metric/size
  613. // property
  614. //
  615. // hTheme - theme data handle
  616. // hdc - (optional) hdc to be drawn into (DPI scaling)
  617. // iPartId - part number
  618. // iStateId - state number of part
  619. // iPropId - the property number to get the value for
  620. // piVal - receives the value of the property
  621. //----------------------------------------------------------------------------------------------------------------------
  622. var
  623. GetThemeMetric: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId, iPropId: Integer;
  624. var piVal: Integer): HRESULT; stdcall;
  625. {$EXTERNALSYM GetThemeMetric}
  626. //----------------------------------------------------------------------------------------------------------------------
  627. // GetThemeString() - Get the value for the specified string property
  628. //
  629. // hTheme - theme data handle
  630. // iPartId - part number
  631. // iStateId - state number of part
  632. // iPropId - the property number to get the value for
  633. // pszBuff - receives the string property value
  634. // cchMaxBuffChars - max. number of chars allowed in pszBuff
  635. //----------------------------------------------------------------------------------------------------------------------
  636. var
  637. GetThemeString: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer; pszBuff: LPWSTR;
  638. cchMaxBuffChars: Integer): HRESULT; stdcall;
  639. {$EXTERNALSYM GetThemeString}
  640. //----------------------------------------------------------------------------------------------------------------------
  641. // GetThemeBool() - Get the value for the specified BOOL property
  642. //
  643. // hTheme - theme data handle
  644. // iPartId - part number
  645. // iStateId - state number of part
  646. // iPropId - the property number to get the value for
  647. // pfVal - receives the value of the property
  648. //----------------------------------------------------------------------------------------------------------------------
  649. var
  650. GetThemeBool: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer; var pfVal: BOOL): HRESULT; stdcall;
  651. {$EXTERNALSYM GetThemeBool}
  652. //----------------------------------------------------------------------------------------------------------------------
  653. // GetThemeInt() - Get the value for the specified int property
  654. //
  655. // hTheme - theme data handle
  656. // iPartId - part number
  657. // iStateId - state number of part
  658. // iPropId - the property number to get the value for
  659. // piVal - receives the value of the property
  660. //----------------------------------------------------------------------------------------------------------------------
  661. var
  662. GetThemeInt: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer; var piVal: Integer): HRESULT; stdcall;
  663. {$EXTERNALSYM GetThemeInt}
  664. //----------------------------------------------------------------------------------------------------------------------
  665. // GetThemeEnumValue() - Get the value for the specified ENUM property
  666. //
  667. // hTheme - theme data handle
  668. // iPartId - part number
  669. // iStateId - state number of part
  670. // iPropId - the property number to get the value for
  671. // piVal - receives the value of the enum (cast to int*)
  672. //----------------------------------------------------------------------------------------------------------------------
  673. var
  674. GetThemeEnumValue: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer; var piVal: Integer): HRESULT; stdcall;
  675. {$EXTERNALSYM GetThemeEnumValue}
  676. //----------------------------------------------------------------------------------------------------------------------
  677. // GetThemePosition() - Get the value for the specified position
  678. // property
  679. //
  680. // hTheme - theme data handle
  681. // iPartId - part number
  682. // iStateId - state number of part
  683. // iPropId - the property number to get the value for
  684. // pPoint - receives the value of the position property
  685. //----------------------------------------------------------------------------------------------------------------------
  686. var
  687. GetThemePosition: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer;var pPoint: TPoint): HRESULT; stdcall;
  688. {$EXTERNALSYM GetThemePosition}
  689. //----------------------------------------------------------------------------------------------------------------------
  690. // GetThemeFont() - Get the value for the specified font property
  691. //
  692. // hTheme - theme data handle
  693. // hdc - (optional) hdc to be drawn to (DPI scaling)
  694. // iPartId - part number
  695. // iStateId - state number of part
  696. // iPropId - the property number to get the value for
  697. // pFont - receives the value of the LOGFONT property
  698. // (scaled for the current logical screen dpi)
  699. //----------------------------------------------------------------------------------------------------------------------
  700. var
  701. GetThemeFont: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId, iPropId: Integer;
  702. var pFont: LOGFONTW): HRESULT; stdcall;
  703. {$EXTERNALSYM GetThemeFont}
  704. //----------------------------------------------------------------------------------------------------------------------
  705. // GetThemeRect() - Get the value for the specified RECT property
  706. //
  707. // hTheme - theme data handle
  708. // iPartId - part number
  709. // iStateId - state number of part
  710. // iPropId - the property number to get the value for
  711. // pRect - receives the value of the RECT property
  712. //----------------------------------------------------------------------------------------------------------------------
  713. var
  714. GetThemeRect: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer; var pRect: TRect): HRESULT; stdcall;
  715. {$EXTERNALSYM GetThemeRect}
  716. //----------------------------------------------------------------------------------------------------------------------
  717. type
  718. _MARGINS = record
  719. cxLeftWidth: Integer; // width of left border that retains its size
  720. cxRightWidth: Integer; // width of right border that retains its size
  721. cyTopHeight: Integer; // height of top border that retains its size
  722. cyBottomHeight: Integer; // height of bottom border that retains its size
  723. end;
  724. {$EXTERNALSYM _MARGINS}
  725. MARGINS = _MARGINS;
  726. {$EXTERNALSYM MARGINS}
  727. PMARGINS = ^MARGINS;
  728. {$EXTERNALSYM PMARGINS}
  729. TMargins = MARGINS;
  730. //----------------------------------------------------------------------------------------------------------------------
  731. // GetThemeMargins() - Get the value for the specified MARGINS property
  732. //
  733. // hTheme - theme data handle
  734. // hdc - (optional) hdc to be used for drawing
  735. // iPartId - part number
  736. // iStateId - state number of part
  737. // iPropId - the property number to get the value for
  738. // prc - RECT for area to be drawn into
  739. // pMargins - receives the value of the MARGINS property
  740. //----------------------------------------------------------------------------------------------------------------------
  741. var
  742. GetThemeMargins: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId, iPropId: Integer; prc: PRECT;
  743. var pMargins: MARGINS): HRESULT; stdcall;
  744. {$EXTERNALSYM GetThemeMargins}
  745. //----------------------------------------------------------------------------------------------------------------------
  746. (* how to translate?
  747. {$IF _WIN32_WINNT >= 0x0600}
  748. MAX_INTLIST_COUNT = 402;
  749. {$ELSE}
  750. MAX_INTLIST_COUNT = 10;
  751. {$ENDIF}
  752. *)
  753. const
  754. MAX_INTLIST_COUNT = 10;
  755. {$EXTERNALSYM MAX_INTLIST_COUNT}
  756. type
  757. _INTLIST = record
  758. iValueCount: Integer; // number of values in iValues
  759. iValues: array [0..MAX_INTLIST_COUNT - 1] of Integer;
  760. end;
  761. {$EXTERNALSYM _INTLIST}
  762. INTLIST = _INTLIST;
  763. {$EXTERNALSYM INTLIST}
  764. PINTLIST = ^INTLIST;
  765. {$EXTERNALSYM PINTLIST}
  766. TIntList = INTLIST;
  767. //----------------------------------------------------------------------------------------------------------------------
  768. // GetThemeIntList() - Get the value for the specified INTLIST struct
  769. //
  770. // hTheme - theme data handle
  771. // iPartId - part number
  772. // iStateId - state number of part
  773. // iPropId - the property number to get the value for
  774. // pIntList - receives the value of the INTLIST property
  775. //----------------------------------------------------------------------------------------------------------------------
  776. var
  777. GetThemeIntList: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer; var pIntList: INTLIST): HRESULT; stdcall;
  778. {$EXTERNALSYM GetThemeIntList}
  779. //----------------------------------------------------------------------------------------------------------------------
  780. type
  781. PROPERTYORIGIN = (
  782. PO_STATE, // property was found in the state section
  783. PO_PART, // property was found in the part section
  784. PO_CLASS, // property was found in the class section
  785. PO_GLOBAL, // property was found in [globals] section
  786. PO_NOTFOUND); // property was not found
  787. {$EXTERNALSYM PROPERTYORIGIN}
  788. TPropertyOrigin = PROPERTYORIGIN;
  789. //----------------------------------------------------------------------------------------------------------------------
  790. // GetThemePropertyOrigin()
  791. // - searches for the specified theme property
  792. // and sets "pOrigin" to indicate where it was
  793. // found (or not found)
  794. //
  795. // hTheme - theme data handle
  796. // iPartId - part number
  797. // iStateId - state number of part
  798. // iPropId - the property number to search for
  799. // pOrigin - receives the value of the property origin
  800. //----------------------------------------------------------------------------------------------------------------------
  801. var
  802. GetThemePropertyOrigin: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer;
  803. var pOrigin: PROPERTYORIGIN): HRESULT; stdcall;
  804. {$EXTERNALSYM GetThemePropertyOrigin}
  805. //----------------------------------------------------------------------------------------------------------------------
  806. // SetWindowTheme()
  807. // - redirects an existing Window to use a different
  808. // section of the current theme information than its
  809. // class normally asks for.
  810. //
  811. // hwnd - the handle of the window (cannot be NULL)
  812. //
  813. // pszSubAppName - app (group) name to use in place of the calling
  814. // app's name. If NULL, the actual calling app
  815. // name will be used.
  816. //
  817. // pszSubIdList - semicolon separated list of class Id names to
  818. // use in place of actual list passed by the
  819. // window's class. if NULL, the id list from the
  820. // calling class is used.
  821. //----------------------------------------------------------------------------------------------------------------------
  822. // The Theme Manager will remember the "pszSubAppName" and the
  823. // "pszSubIdList" associations thru the lifetime of the window (even
  824. // if themes are subsequently changed). The window is sent a
  825. // "WM_THEMECHANGED" msg at the end of this call, so that the new
  826. // theme can be found and applied.
  827. //----------------------------------------------------------------------------------------------------------------------
  828. // When "pszSubAppName" or "pszSubIdList" are NULL, the Theme Manager
  829. // removes the previously remember association. To turn off theme-ing for
  830. // the specified window, you can pass an empty string (L"") so it
  831. // won't match any section entries.
  832. //----------------------------------------------------------------------------------------------------------------------
  833. var
  834. SetWindowTheme: function(hwnd: HWND; pszSubAppName: LPCWSTR; pszSubIdList: LPCWSTR): HRESULT; stdcall;
  835. {$EXTERNALSYM SetWindowTheme}
  836. //----------------------------------------------------------------------------------------------------------------------
  837. // GetThemeFilename() - Get the value for the specified FILENAME property.
  838. //
  839. // hTheme - theme data handle
  840. // iPartId - part number
  841. // iStateId - state number of part
  842. // iPropId - the property number to search for
  843. // pszThemeFileName - output buffer to receive the filename
  844. // cchMaxBuffChars - the size of the return buffer, in chars
  845. //----------------------------------------------------------------------------------------------------------------------
  846. var
  847. GetThemeFilename: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer; pszThemeFileName: LPWSTR;
  848. cchMaxBuffChars: Integer): HRESULT; stdcall;
  849. {$EXTERNALSYM GetThemeFilename}
  850. //----------------------------------------------------------------------------------------------------------------------
  851. // GetThemeSysColor() - Get the value of the specified System color.
  852. //
  853. // hTheme - the theme data handle. if non-NULL, will return
  854. // color from [SysMetrics] section of theme.
  855. // if NULL, will return the global system color.
  856. //
  857. // iColorId - the system color index defined in winuser.h
  858. //----------------------------------------------------------------------------------------------------------------------
  859. var
  860. GetThemeSysColor: function(hTheme: HTHEME; iColorId: Integer): COLORREF; stdcall;
  861. {$EXTERNALSYM GetThemeSysColor}
  862. //----------------------------------------------------------------------------------------------------------------------
  863. // GetThemeSysColorBrush()
  864. // - Get the brush for the specified System color.
  865. //
  866. // hTheme - the theme data handle. if non-NULL, will return
  867. // brush matching color from [SysMetrics] section of
  868. // theme. if NULL, will return the brush matching
  869. // global system color.
  870. //
  871. // iColorId - the system color index defined in winuser.h
  872. //----------------------------------------------------------------------------------------------------------------------
  873. var
  874. GetThemeSysColorBrush: function(hTheme: HTHEME; iColorId: Integer): HBRUSH; stdcall;
  875. {$EXTERNALSYM GetThemeSysColorBrush}
  876. //----------------------------------------------------------------------------------------------------------------------
  877. // GetThemeSysBool() - Get the boolean value of specified System metric.
  878. //
  879. // hTheme - the theme data handle. if non-NULL, will return
  880. // BOOL from [SysMetrics] section of theme.
  881. // if NULL, will return the specified system boolean.
  882. //
  883. // iBoolId - the TMT_XXX BOOL number (first BOOL
  884. // is TMT_FLATMENUS)
  885. //----------------------------------------------------------------------------------------------------------------------
  886. var
  887. GetThemeSysBool: function(hTheme: HTHEME; iBoolId: Integer): BOOL; stdcall;
  888. {$EXTERNALSYM GetThemeSysBool}
  889. //----------------------------------------------------------------------------------------------------------------------
  890. // GetThemeSysSize() - Get the value of the specified System size metric.
  891. // (scaled for the current logical screen dpi)
  892. //
  893. // hTheme - the theme data handle. if non-NULL, will return
  894. // size from [SysMetrics] section of theme.
  895. // if NULL, will return the global system metric.
  896. //
  897. // iSizeId - the following values are supported when
  898. // hTheme is non-NULL:
  899. //
  900. // SM_CXBORDER (border width)
  901. // SM_CXVSCROLL (scrollbar width)
  902. // SM_CYHSCROLL (scrollbar height)
  903. // SM_CXSIZE (caption width)
  904. // SM_CYSIZE (caption height)
  905. // SM_CXSMSIZE (small caption width)
  906. // SM_CYSMSIZE (small caption height)
  907. // SM_CXMENUSIZE (menubar width)
  908. // SM_CYMENUSIZE (menubar height)
  909. //
  910. // when hTheme is NULL, iSizeId is passed directly
  911. // to the GetSystemMetrics() function
  912. //----------------------------------------------------------------------------------------------------------------------
  913. var
  914. GetThemeSysSize: function(hTheme: HTHEME; iSizeId: Integer): Integer; stdcall;
  915. {$EXTERNALSYM GetThemeSysSize}
  916. //----------------------------------------------------------------------------------------------------------------------
  917. // GetThemeSysFont() - Get the LOGFONT for the specified System font.
  918. //
  919. // hTheme - the theme data handle. if non-NULL, will return
  920. // font from [SysMetrics] section of theme.
  921. // if NULL, will return the specified system font.
  922. //
  923. // iFontId - the TMT_XXX font number (first font
  924. // is TMT_CAPTIONFONT)
  925. //
  926. // plf - ptr to LOGFONT to receive the font value.
  927. // (scaled for the current logical screen dpi)
  928. //----------------------------------------------------------------------------------------------------------------------
  929. var
  930. GetThemeSysFont: function(hTheme: HTHEME; iFontId: Integer; var plf: LOGFONTW): HRESULT; stdcall;
  931. {$EXTERNALSYM GetThemeSysFont}
  932. //----------------------------------------------------------------------------------------------------------------------
  933. // GetThemeSysString() - Get the value of specified System string metric.
  934. //
  935. // hTheme - the theme data handle (required)
  936. //
  937. // iStringId - must be one of the following values:
  938. //
  939. // TMT_CSSNAME
  940. // TMT_XMLNAME
  941. //
  942. // pszStringBuff - the buffer to receive the string value
  943. //
  944. // cchMaxStringChars - max. number of chars that pszStringBuff can hold
  945. //----------------------------------------------------------------------------------------------------------------------
  946. var
  947. GetThemeSysString: function(hTheme: HTHEME; iStringId: Integer; pszStringBuff: LPWSTR;
  948. cchMaxStringChars: Integer): HRESULT; stdcall;
  949. {$EXTERNALSYM GetThemeSysString}
  950. //----------------------------------------------------------------------------------------------------------------------
  951. // GetThemeSysInt() - Get the value of specified System int.
  952. //
  953. // hTheme - the theme data handle (required)
  954. //
  955. // iIntId - must be one of the following values:
  956. //
  957. // TMT_DPIX
  958. // TMT_DPIY
  959. // TMT_MINCOLORDEPTH
  960. //
  961. // piValue - ptr to int to receive value
  962. //----------------------------------------------------------------------------------------------------------------------
  963. var
  964. GetThemeSysInt: function(hTheme: HTHEME; iIntId: Integer; var piValue: Integer): HRESULT; stdcall;
  965. {$EXTERNALSYM GetThemeSysInt}
  966. //----------------------------------------------------------------------------------------------------------------------
  967. // IsThemeActive() - can be used to test if a system theme is active
  968. // for the current user session.
  969. //
  970. // use the API "IsAppThemed()" to test if a theme is
  971. // active for the calling process.
  972. //----------------------------------------------------------------------------------------------------------------------
  973. var
  974. IsThemeActive: function: BOOL; stdcall;
  975. {$EXTERNALSYM IsThemeActive}
  976. //----------------------------------------------------------------------------------------------------------------------
  977. // IsAppThemed() - returns TRUE if a theme is active and available to
  978. // the current process
  979. //----------------------------------------------------------------------------------------------------------------------
  980. var
  981. IsAppThemed: function: BOOL; stdcall;
  982. {$EXTERNALSYM IsAppThemed}
  983. //----------------------------------------------------------------------------------------------------------------------
  984. // GetWindowTheme() - if window is themed, returns its most recent
  985. // HTHEME from OpenThemeData() - otherwise, returns
  986. // NULL.
  987. //
  988. // hwnd - the window to get the HTHEME of
  989. //----------------------------------------------------------------------------------------------------------------------
  990. var
  991. GetWindowTheme: function(hwnd: HWND): HTHEME; stdcall;
  992. {$EXTERNALSYM GetWindowTheme}
  993. //----------------------------------------------------------------------------------------------------------------------
  994. // EnableThemeDialogTexture()
  995. //
  996. // - Enables/disables dialog background theme. This method can be used to
  997. // tailor dialog compatibility with child windows and controls that
  998. // may or may not coordinate the rendering of their client area backgrounds
  999. // with that of their parent dialog in a manner that supports seamless
  1000. // background texturing.
  1001. //
  1002. // hdlg - the window handle of the target dialog
  1003. // dwFlags - ETDT_ENABLE to enable the theme-defined dialog background texturing,
  1004. // ETDT_DISABLE to disable background texturing,
  1005. // ETDT_ENABLETAB to enable the theme-defined background
  1006. // texturing using the Tab texture
  1007. //----------------------------------------------------------------------------------------------------------------------
  1008. const
  1009. ETDT_DISABLE = $00000001;
  1010. {$EXTERNALSYM ETDT_DISABLE}
  1011. ETDT_ENABLE = $00000002;
  1012. {$EXTERNALSYM ETDT_ENABLE}
  1013. ETDT_USETABTEXTURE = $00000004;
  1014. {$EXTERNALSYM ETDT_USETABTEXTURE}
  1015. ETDT_ENABLETAB = (ETDT_ENABLE or ETDT_USETABTEXTURE);
  1016. {$EXTERNALSYM ETDT_ENABLETAB}
  1017. var
  1018. EnableThemeDialogTexture: function(hwnd: HWND; dwFlags: DWORD): HRESULT; stdcall;
  1019. {$EXTERNALSYM EnableThemeDialogTexture}
  1020. //----------------------------------------------------------------------------------------------------------------------
  1021. // IsThemeDialogTextureEnabled()
  1022. //
  1023. // - Reports whether the dialog supports background texturing.
  1024. //
  1025. // hdlg - the window handle of the target dialog
  1026. //----------------------------------------------------------------------------------------------------------------------
  1027. var
  1028. IsThemeDialogTextureEnabled: function(hwnd: HWND): BOOL; stdcall;
  1029. {$EXTERNALSYM IsThemeDialogTextureEnabled}
  1030. //----------------------------------------------------------------------------------------------------------------------
  1031. //---- flags to control theming within an app ----
  1032. const
  1033. STAP_ALLOW_NONCLIENT = (1 shl 0);
  1034. {$EXTERNALSYM STAP_ALLOW_NONCLIENT}
  1035. STAP_ALLOW_CONTROLS = (1 shl 1);
  1036. {$EXTERNALSYM STAP_ALLOW_CONTROLS}
  1037. STAP_ALLOW_WEBCONTENT = (1 shl 2);
  1038. {$EXTERNALSYM STAP_ALLOW_WEBCONTENT}
  1039. STAP_VALIDBITS = (STAP_ALLOW_NONCLIENT or STAP_ALLOW_CONTROLS or STAP_ALLOW_WEBCONTENT);
  1040. {$EXTERNALSYM STAP_VALIDBITS}
  1041. //----------------------------------------------------------------------------------------------------------------------
  1042. // GetThemeAppProperties()
  1043. // - returns the app property flags that control theming
  1044. //----------------------------------------------------------------------------------------------------------------------
  1045. var
  1046. GetThemeAppProperties: function: DWORD; stdcall;
  1047. {$EXTERNALSYM GetThemeAppProperties}
  1048. //----------------------------------------------------------------------------------------------------------------------
  1049. // SetThemeAppProperties()
  1050. // - sets the flags that control theming within the app
  1051. //
  1052. // dwFlags - the flag values to be set
  1053. //----------------------------------------------------------------------------------------------------------------------
  1054. var
  1055. SetThemeAppProperties: procedure(dwFlags: DWORD); stdcall;
  1056. {$EXTERNALSYM SetThemeAppProperties}
  1057. //----------------------------------------------------------------------------------------------------------------------
  1058. // GetCurrentThemeName()
  1059. // - Get the name of the current theme in-use.
  1060. // Optionally, return the ColorScheme name and the
  1061. // Size name of the theme.
  1062. //
  1063. // pszThemeFileName - receives the theme path & filename
  1064. // cchMaxNameChars - max chars allowed in pszNameBuff
  1065. //
  1066. // pszColorBuff - (optional) receives the canonical color scheme name
  1067. // (not the display name)
  1068. // cchMaxColorChars - max chars allowed in pszColorBuff
  1069. //
  1070. // pszSizeBuff - (optional) receives the canonical size name
  1071. // (not the display name)
  1072. // cchMaxSizeChars - max chars allowed in pszSizeBuff
  1073. //----------------------------------------------------------------------------------------------------------------------
  1074. var
  1075. GetCurrentThemeName: function(pszThemeFileName: LPWSTR; cchMaxNameChars: Integer; pszColorBuff: LPWSTR;
  1076. cchMaxColorChars: Integer; pszSizeBuff: LPWSTR; cchMaxSizeChars: Integer): HRESULT; stdcall;
  1077. {$EXTERNALSYM GetCurrentThemeName}
  1078. //----------------------------------------------------------------------------------------------------------------------
  1079. // GetThemeDocumentationProperty()
  1080. // - Get the value for the specified property name from
  1081. // the [documentation] section of the themes.ini file
  1082. // for the specified theme. If the property has been
  1083. // localized in the theme files string table, the
  1084. // localized version of the property value is returned.
  1085. //
  1086. // pszThemeFileName - filename of the theme file to query
  1087. // pszPropertyName - name of the string property to retreive a value for
  1088. // pszValueBuff - receives the property string value
  1089. // cchMaxValChars - max chars allowed in pszValueBuff
  1090. //----------------------------------------------------------------------------------------------------------------------
  1091. const
  1092. SZ_THDOCPROP_DISPLAYNAME = WideString('DisplayName');
  1093. {$EXTERNALSYM SZ_THDOCPROP_DISPLAYNAME}
  1094. SZ_THDOCPROP_CANONICALNAME = WideString('ThemeName');
  1095. {$EXTERNALSYM SZ_THDOCPROP_CANONICALNAME}
  1096. SZ_THDOCPROP_TOOLTIP = WideString('ToolTip');
  1097. {$EXTERNALSYM SZ_THDOCPROP_TOOLTIP}
  1098. SZ_THDOCPROP_AUTHOR = WideString('author');
  1099. {$EXTERNALSYM SZ_THDOCPROP_AUTHOR}
  1100. var
  1101. GetThemeDocumentationProperty: function(pszThemeName, pszPropertyName: LPCWSTR; pszValueBuff: LPWSTR;
  1102. cchMaxValChars: Integer): HRESULT; stdcall;
  1103. {$EXTERNALSYM GetThemeDocumentationProperty}
  1104. //----------------------------------------------------------------------------------------------------------------------
  1105. // Theme API Error Handling
  1106. //
  1107. // All functions in the Theme API not returning an HRESULT (THEMEAPI_)
  1108. // use the WIN32 function "SetLastError()" to record any call failures.
  1109. //
  1110. // To retreive the error code of the last failure on the
  1111. // current thread for these type of API's, use the WIN32 function
  1112. // "GetLastError()".
  1113. //
  1114. // All Theme API error codes (HRESULT's and GetLastError() values)
  1115. // should be normal win32 errors which can be formatted into
  1116. // strings using the Win32 API FormatMessage().
  1117. //----------------------------------------------------------------------------------------------------------------------
  1118. //----------------------------------------------------------------------------------------------------------------------
  1119. // DrawThemeParentBackground()
  1120. // - used by partially-transparent or alpha-blended
  1121. // child controls to draw the part of their parent
  1122. // that they appear in front of.
  1123. //
  1124. // hwnd - handle of the child control
  1125. // hdc - hdc of the child control
  1126. // prc - (optional) rect that defines the area to be
  1127. // drawn (CHILD coordinates)
  1128. //----------------------------------------------------------------------------------------------------------------------
  1129. var
  1130. DrawThemeParentBackground: function(hwnd: HWND; hdc: HDC; prc: PRECT): HRESULT; stdcall;
  1131. {$EXTERNALSYM DrawThemeParentBackground}
  1132. //----------------------------------------------------------------------------------------------------------------------
  1133. // EnableTheming() - enables or disables themeing for the current user
  1134. // in the current and future sessions.
  1135. //
  1136. // fEnable - if FALSE, disable theming & turn themes off.
  1137. // - if TRUE, enable themeing and, if user previously
  1138. // had a theme active, make it active now.
  1139. //----------------------------------------------------------------------------------------------------------------------
  1140. var
  1141. EnableTheming: function(fEnable: BOOL): HRESULT; stdcall;
  1142. {$EXTERNALSYM EnableTheming}
  1143. const
  1144. GBF_DIRECT = $00000001; // direct dereferencing.
  1145. {$EXTERNALSYM GBF_DIRECT}
  1146. GBF_COPY = $00000002; // create a copy of the bitmap
  1147. {$EXTERNALSYM GBF_COPY}
  1148. GBF_VALIDBITS = (GBF_DIRECT or GBF_COPY);
  1149. {$EXTERNALSYM GBF_VALIDBITS}
  1150. // if (_WIN32_WINNT >= 0x0600)
  1151. const
  1152. DTPB_WINDOWDC = $00000001;
  1153. {$EXTERNALSYM DTPB_WINDOWDC}
  1154. DTPB_USECTLCOLORSTATIC = $00000002;
  1155. {$EXTERNALSYM DTPB_USECTLCOLORSTATIC}
  1156. DTPB_USEERASEBKGND = $00000004;
  1157. {$EXTERNALSYM DTPB_USEERASEBKGND}
  1158. //---------------------------------------------------------------------------
  1159. // DrawThemeParentBackgroundEx()
  1160. // - used by partially-transparent or alpha-blended
  1161. // child controls to draw the part of their parent
  1162. // that they appear in front of.
  1163. // Sends a WM_ERASEBKGND message followed by a WM_PRINTCLIENT.
  1164. //
  1165. // hwnd - handle of the child control
  1166. //
  1167. // hdc - hdc of the child control
  1168. //
  1169. // dwFlags - if 0, only returns S_OK if the parent handled
  1170. // WM_PRINTCLIENT.
  1171. // - if DTPB_WINDOWDC is set, hdc is assumed to be a window DC,
  1172. // not a client DC.
  1173. // - if DTPB_USEERASEBKGND is set, the function will return S_OK
  1174. // without sending a WM_CTLCOLORSTATIC message if the parent
  1175. // actually painted on WM_ERASEBKGND.
  1176. // - if DTPB_CTLCOLORSTATIC is set, the function will send
  1177. // a WM_CTLCOLORSTATIC message to the parent and use the
  1178. // brush if one is provided, else COLOR_BTNFACE.
  1179. //
  1180. // prc - (optional) rect that defines the area to be
  1181. // drawn (CHILD coordinates)
  1182. //
  1183. // Return value - S_OK if something was painted, S_FALSE if not.
  1184. //---------------------------------------------------------------------------
  1185. var
  1186. DrawThemeParentBackgroundEx: function(hwnd: HWND; hdc: HDC; dwFlags: DWORD; prc: PRect): HRESULT; stdcall;
  1187. {$EXTERNALSYM DrawThemeParentBackgroundEx}
  1188. const
  1189. WTA_NONCLIENT = 1;
  1190. {$EXTERNALSYM WTA_NONCLIENT}
  1191. type
  1192. _WTA_OPTIONS = record
  1193. dwFlags: DWORD; // values for each style option specified in the bitmask
  1194. dwMask: DWORD; // bitmask for flags that are changing
  1195. // valid options are: WTNCA_NODRAWCAPTION, WTNCA_NODRAWICON, WTNCA_NOSYSMENU
  1196. end;
  1197. {$EXTERNALSYM _WTA_OPTIONS}
  1198. WTA_OPTIONS = _WTA_OPTIONS;
  1199. {$EXTERNALSYM WTA_OPTIONS}
  1200. PWTA_OPTIONS = ^_WTA_OPTIONS;
  1201. {$EXTERNALSYM PWTA_OPTIONS}
  1202. TWTA_Options = WTA_OPTIONS;
  1203. const
  1204. WTNCA_NODRAWCAPTION = $00000001; // don't draw the window caption
  1205. {$EXTERNALSYM WTNCA_NODRAWCAPTION}
  1206. WTNCA_NODRAWICON = $00000002; // don't draw the system icon
  1207. {$EXTERNALSYM WTNCA_NODRAWICON}
  1208. WTNCA_NOSYSMENU = $00000004; // don't expose the system menu icon functionality
  1209. {$EXTERNALSYM WTNCA_NOSYSMENU}
  1210. WTNCA_NOMIRRORHELP = $00000008; // don't mirror the question mark, even in RTL layout
  1211. {$EXTERNALSYM WTNCA_NOMIRRORHELP}
  1212. WTNCA_VALIDBITS = (WTNCA_NODRAWCAPTION or WTNCA_NODRAWICON or WTNCA_NOSYSMENU or WTNCA_NOMIRRORHELP);
  1213. {$EXTERNALSYM WTNCA_VALIDBITS}
  1214. var
  1215. SetWindowThemeAttribute: function(hwnd: HWND; eAttribute: LongWord; pvAttribute: Pointer; cbAttribute: DWORD): HRESULT; stdcall;
  1216. {$EXTERNALSYM SetWindowThemeAttribute}
  1217. function SetWindowThemeNonClientAttributes(hwnd: HWND; dwMask: DWORD; dwAttributes: DWORD): HRESULT;
  1218. {$EXTERNALSYM SetWindowThemeNonClientAttributes}
  1219. // endif // if (_WIN32_WINNT >= 0x0600)
  1220. //---------------------------------------------------------------------------
  1221. //
  1222. // DrawThemeTextEx
  1223. //
  1224. // Note: DrawThemeTextEx only exists on Windows Vista and higher, but the
  1225. // following declarations are provided to enable declaring its prototype when
  1226. // compiling for all platforms.
  1227. // Callback function used by DrawThemeTextEx, instead of DrawText
  1228. type
  1229. DTT_CALLBACK_PROC = function(hdc: HDC; pszText: LPCWSTR; cchText: Integer; prc: PRect;
  1230. dwFlags: UINT; lParam: LPARAM): Integer; stdcall;
  1231. {$EXTERNALSYM DTT_CALLBACK_PROC}
  1232. //---- bits used in dwFlags of DTTOPTS ----
  1233. const
  1234. DTT_TEXTCOLOR = (1 shl 0); // crText has been specified
  1235. {$EXTERNALSYM DTT_TEXTCOLOR}
  1236. DTT_BORDERCOLOR = (1 shl 1); // crBorder has been specified
  1237. {$EXTERNALSYM DTT_BORDERCOLOR}
  1238. DTT_SHADOWCOLOR = (1 shl 2); // crShadow has been specified
  1239. {$EXTERNALSYM DTT_SHADOWCOLOR}
  1240. DTT_SHADOWTYPE = (1 shl 3); // iTextShadowType has been specified
  1241. {$EXTERNALSYM DTT_SHADOWTYPE}
  1242. DTT_SHADOWOFFSET = (1 shl 4); // ptShadowOffset has been specified
  1243. {$EXTERNALSYM DTT_SHADOWOFFSET}
  1244. DTT_BORDERSIZE = (1 shl 5); // iBorderSize has been specified
  1245. {$EXTERNALSYM DTT_BORDERSIZE}
  1246. DTT_FONTPROP = (1 shl 6); // iFontPropId has been specified
  1247. {$EXTERNALSYM DTT_FONTPROP}
  1248. DTT_COLORPROP = (1 shl 7); // iColorPropId has been specified
  1249. {$EXTERNALSYM DTT_COLORPROP}
  1250. DTT_STATEID = (1 shl 8); // IStateId has been specified
  1251. {$EXTERNALSYM DTT_STATEID}
  1252. DTT_CALCRECT = (1 shl 9); // Use pRect as and in/out parameter
  1253. {$EXTERNALSYM DTT_CALCRECT}
  1254. DTT_APPLYOVERLAY = (1 shl 10); // fApplyOverlay has been specified
  1255. {$EXTERNALSYM DTT_APPLYOVERLAY}
  1256. DTT_GLOWSIZE = (1 shl 11); // iGlowSize has been specified
  1257. {$EXTERNALSYM DTT_GLOWSIZE}
  1258. DTT_CALLBACK = (1 shl 12); // pfnDrawTextCallback has been specified
  1259. {$EXTERNALSYM DTT_CALLBACK}
  1260. DTT_COMPOSITED = (1 shl 13); // Draws text with antialiased alpha (needs a DIB section)
  1261. {$EXTERNALSYM DTT_COMPOSITED}
  1262. DTT_VALIDBITS = (DTT_TEXTCOLOR or DTT_BORDERCOLOR or DTT_SHADOWCOLOR or
  1263. DTT_SHADOWTYPE or DTT_SHADOWOFFSET or DTT_BORDERSIZE or
  1264. DTT_FONTPROP or DTT_COLORPROP or DTT_STATEID or
  1265. DTT_CALCRECT or DTT_APPLYOVERLAY or DTT_GLOWSIZE or
  1266. DTT_COMPOSITED);
  1267. {$EXTERNALSYM DTT_VALIDBITS}
  1268. type
  1269. _DTTOPTS = record
  1270. dwSize: DWORD; // size of the struct
  1271. dwFlags: DWORD; // which options have been specified
  1272. crText: COLORREF; // color to use for text fill
  1273. crBorder: COLORREF; // color to use for text outline
  1274. crShadow: COLORREF; // color to use for text shadow
  1275. iTextShadowType: Integer; // TST_SINGLE or TST_CONTINUOUS
  1276. ptShadowOffset: TPoint; // where shadow is drawn (relative to text)
  1277. iBorderSize: Integer; // Border radius around text
  1278. iFontPropId: Integer; // Font property to use for the text instead of TMT_FONT
  1279. iColorPropId: Integer; // Color property to use for the text instead of TMT_TEXTCOLOR
  1280. iStateId: Integer; // Alternate state id
  1281. fApplyOverlay: BOOL; // Overlay text on top of any text effect?
  1282. iGlowSize: Integer; // Glow radious around text
  1283. pfnDrawTextCallback: DTT_CALLBACK_PROC; // Callback for DrawText
  1284. lParam: LPARAM; // Parameter for callback
  1285. end;
  1286. {$EXTERNALSYM _DTTOPTS}
  1287. DTTOPTS = _DTTOPTS;
  1288. {$EXTERNALSYM DTTOPTS}
  1289. PDTTOPTS = ^_DTTOPTS;
  1290. {$EXTERNALSYM PDTTOPTS}
  1291. TDTTOpts = DTTOPTS;
  1292. // if (_WIN32_WINNT >= 0x0600)
  1293. var
  1294. DrawThemeTextEx: function(hTheme: HTHEME; hdc: HDC; iPartId, iStateId: Integer; pszText: LPCWSTR;
  1295. cchText: Integer; dwTextFlags: DWORD; pRect: PRect; pOptions: PDTTOPTS): HRESULT; stdcall;
  1296. {$EXTERNALSYM DrawThemeTextEx}
  1297. //-----------------------------------------------------------------------
  1298. // GetThemeStream() - Get the value for the specified STREAM property
  1299. //
  1300. // hTheme - theme data handle
  1301. // iPartId - part number
  1302. // iStateId - state number of part
  1303. // iPropId - the property number to get the value for
  1304. // ppvStream - if non-null receives the value of the STREAM property (not to be freed)
  1305. // pcbStream - if non-null receives the size of the STREAM property
  1306. // hInst - NULL when iPropId==TMT_STREAM, HINSTANCE of a loaded msstyles
  1307. // file when iPropId==TMT_DISKSTREAM (use GetCurrentThemeName
  1308. // and LoadLibraryEx(LOAD_LIBRARY_AS_DATAFILE)
  1309. //-----------------------------------------------------------------------
  1310. var
  1311. GetThemeBitmap: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer; dwFlags: ULONG;
  1312. var phBitmap: HBITMAP): HRESULT; stdcall;
  1313. {$EXTERNALSYM GetThemeBitmap}
  1314. //-----------------------------------------------------------------------
  1315. // GetThemeStream() - Get the value for the specified STREAM property
  1316. //
  1317. // hTheme - theme data handle
  1318. // iPartId - part number
  1319. // iStateId - state number of part
  1320. // iPropId - the property number to get the value for
  1321. // ppvStream - if non-null receives the value of the STREAM property (not to be freed)
  1322. // pcbStream - if non-null receives the size of the STREAM property
  1323. // hInst - NULL when iPropId==TMT_STREAM, HINSTANCE of a loaded msstyles
  1324. // file when iPropId==TMT_DISKSTREAM (use GetCurrentThemeName
  1325. // and LoadLibraryEx(LOAD_LIBRARY_AS_DATAFILE)
  1326. //-----------------------------------------------------------------------
  1327. var
  1328. GetThemeStream: function(hTheme: HTHEME; iPartId, iStateId, iPropId: Integer; ppvStream: PPointer;
  1329. pcbStream: PDWORD; hInst: HINST): HRESULT; stdcall;
  1330. {$EXTERNALSYM GetThemeStream}
  1331. //------------------------------------------------------------------------
  1332. // BufferedPaintInit() - Initialize the Buffered Paint API.
  1333. // Should be called prior to BeginBufferedPaint,
  1334. // and should have a matching BufferedPaintUnInit.
  1335. //------------------------------------------------------------------------
  1336. var
  1337. BufferedPaintInit: function: HRESULT; stdcall;
  1338. {$EXTERNALSYM BufferedPaintInit}
  1339. //------------------------------------------------------------------------
  1340. // BufferedPaintUnInit() - Uninitialize the Buffered Paint API.
  1341. // Should be called once for each call to BufferedPaintInit,
  1342. // when calls to BeginBufferedPaint are no longer needed.
  1343. //------------------------------------------------------------------------
  1344. var
  1345. BufferedPaintUnInit: function: HRESULT; stdcall;
  1346. {$EXTERNALSYM BufferedPaintUnInit}
  1347. //------------------------------------------------------------------------
  1348. // BeginBufferedPaint() - Begins a buffered paint operation.
  1349. //
  1350. // hdcTarget - Target DC on which the buffer will be painted
  1351. // rcTarget - Rectangle specifying the area of the target DC to paint to
  1352. // dwFormat - Format of the buffer (see BP_BUFFERFORMAT)
  1353. // pPaintParams - Paint operation parameters (see BP_PAINTPARAMS)
  1354. // phBufferedPaint - Pointer to receive handle to new buffered paint context
  1355. //------------------------------------------------------------------------
  1356. // HPAINTBUFFER
  1357. type
  1358. HPAINTBUFFER = HANDLE; // handle to a buffered paint context
  1359. {$EXTERNALSYM HPAINTBUFFER}
  1360. // BP_BUFFERFORMAT
  1361. const
  1362. BPBF_COMPATIBLEBITMAP = 0; // Compatible bitmap
  1363. {$EXTERNALSYM BPBF_COMPATIBLEBITMAP}
  1364. BPBF_DIB = 1; // Device-independent bitmap
  1365. {$EXTERNALSYM BPBF_DIB}
  1366. BPBF_TOPDOWNDIB = 2; // Top-down device-independent bitmap
  1367. {$EXTERNALSYM BPBF_TOPDOWNDIB}
  1368. BPBF_TOPDOWNMONODIB = 3; // Top-down monochrome device-independent bitmap
  1369. {$EXTERNALSYM BPBF_TOPDOWNMONODIB}
  1370. BPBF_COMPOSITED = BPBF_TOPDOWNDIB;
  1371. {$EXTERNALSYM BPBF_COMPOSITED}
  1372. // BP_ANIMATIONSTYLE
  1373. const
  1374. BPAS_NONE = 0; // No animation
  1375. {$EXTERNALSYM BPAS_NONE}
  1376. BPAS_LINEAR = 1; // Linear fade animation
  1377. {$EXTERNALSYM BPAS_LINEAR}
  1378. BPAS_CUBIC = 2; // Cubic fade animation
  1379. {$EXTERNALSYM BPAS_CUBIC}
  1380. BPAS_SINE = 3; // Sinusoid fade animation
  1381. {$EXTERNALSYM BPAS_SINE}
  1382. // BP_ANIMATIONPARAMS
  1383. type
  1384. _BP_ANIMATIONPARAMS = record
  1385. cbSize: DWORD;
  1386. dwFlags: DWORD; // BPAF_ flags
  1387. style: LongWord; // BP_ANIMATIONSTYLE
  1388. dwDuration: DWORD;
  1389. end;
  1390. {$EXTERNALSYM _BP_ANIMATIONPARAMS}
  1391. BP_ANIMATIONPARAMS = _BP_ANIMATIONPARAMS;
  1392. {$EXTERNALSYM BP_ANIMATIONPARAMS}
  1393. PBP_ANIMATIONPARAMS = ^_BP_ANIMATIONPARAMS;
  1394. {$EXTERNALSYM BP_ANIMATIONPARAMS}
  1395. TBP_AnimationParams = _BP_ANIMATIONPARAMS;
  1396. const
  1397. BPPF_ERASE = $0001; // Empty the buffer during BeginBufferedPaint()
  1398. {$EXTERNALSYM BPPF_ERASE}
  1399. BPPF_NOCLIP = $0002; // Don't apply the target DC's clip region to the double buffer
  1400. {$EXTERNALSYM BPPF_NOCLIP}
  1401. BPPF_NONCLIENT = $0004; // Using a non-client DC
  1402. {$EXTERNALSYM BPPF_NONCLIENT}
  1403. // BP_PAINTPARAMS
  1404. type
  1405. _BP_PAINTPARAMS = record
  1406. cbSize: DWORD;
  1407. dwFlags: DWORD; // BPPF_ flags
  1408. prcExclude: PRect;
  1409. pBlendFunction: PBLENDFUNCTION;
  1410. end;
  1411. {$EXTERNALSYM _BP_PAINTPARAMS}
  1412. BP_PAINTPARAMS = _BP_PAINTPARAMS;
  1413. {$EXTERNALSYM BP_PAINTPARAMS}
  1414. PBP_PAINTPARAMS = ^_BP_PAINTPARAMS;
  1415. {$EXTERNALSYM PBP_PAINTPARAMS}
  1416. TBP_PaintParams = _BP_PAINTPARAMS;
  1417. var
  1418. BeginBufferedPaint: function(hdcTarget: HDC; prcTarget: PRECT; dwFormat: LongWord;
  1419. pPaintParams: PBP_PAINTPARAMS; var phdc: HDC): HPAINTBUFFER; stdcall;
  1420. {$EXTERNALSYM BeginBufferedPaint}
  1421. //------------------------------------------------------------------------
  1422. // EndBufferedPaint() - Ends a buffered paint operation.
  1423. //
  1424. // hBufferedPaint - handle to buffered paint context
  1425. // fUpdateTarget - update target DC
  1426. //------------------------------------------------------------------------
  1427. var
  1428. EndBufferedPaint: function(hBufferedPaint: HPAINTBUFFER; fUpdateTarget: BOOL): HRESULT; stdcall;
  1429. {$EXTERNALSYM EndBufferedPaint}
  1430. //------------------------------------------------------------------------
  1431. // GetBufferedPaintTargetRect() - Returns the target rectangle specified during BeginBufferedPaint
  1432. //
  1433. // hBufferedPaint - handle to buffered paint context
  1434. // prc - pointer to receive target rectangle
  1435. //------------------------------------------------------------------------
  1436. var
  1437. GetBufferedPaintTargetRect: function(hBufferedPaint: HPAINTBUFFER; var prc: TRect): HRESULT; stdcall;
  1438. {$EXTERNALSYM GetBufferedPaintTargetRect}
  1439. //------------------------------------------------------------------------
  1440. // GetBufferedPaintTargetDC() - Returns the target DC specified during BeginBufferedPaint
  1441. //
  1442. // hBufferedPaint - handle to buffered paint context
  1443. //------------------------------------------------------------------------
  1444. var
  1445. GetBufferedPaintTargetDC: function(hBufferedPaint: HPAINTBUFFER): HDC; stdcall;
  1446. {$EXTERNALSYM GetBufferedPaintTargetDC}
  1447. //------------------------------------------------------------------------
  1448. // GetBufferedPaintDC() - Returns the same paint DC returned by BeginBufferedPaint
  1449. //
  1450. // hBufferedPaint - handle to buffered paint context
  1451. //------------------------------------------------------------------------
  1452. var
  1453. GetBufferedPaintDC: function(hBufferedPaint: HPAINTBUFFER): HDC; stdcall;
  1454. {$EXTERNALSYM GetBufferedPaintDC}
  1455. //------------------------------------------------------------------------
  1456. // GetBufferedPaintBits() - Obtains a pointer to the buffer bitmap, if the buffer is a DIB
  1457. //
  1458. // hBufferedPaint - handle to buffered paint context
  1459. // ppbBuffer - pointer to receive pointer to buffer bitmap pixels
  1460. // pcxRow - pointer to receive width of buffer bitmap, in pixels;
  1461. // this value may not necessarily be equal to the buffer width
  1462. //------------------------------------------------------------------------
  1463. var
  1464. GetBufferedPaintBits: function(hBufferedPaint: HPAINTBUFFER; var ppbBuffer: PRGBQUAD;
  1465. var pcxRow: Integer): HRESULT; stdcall;
  1466. {$EXTERNALSYM GetBufferedPaintBits}
  1467. //------------------------------------------------------------------------
  1468. // BufferedPaintClear() - Clears given rectangle to ARGB = {0, 0, 0, 0}
  1469. //
  1470. // hBufferedPaint - handle to buffered paint context
  1471. // prc - rectangle to clear; NULL specifies entire buffer
  1472. //------------------------------------------------------------------------
  1473. var
  1474. BufferedPaintClear: function(hBufferedPaint: HPAINTBUFFER; prc: PRect): HRESULT; stdcall;
  1475. {$EXTERNALSYM BufferedPaintClear}
  1476. //------------------------------------------------------------------------
  1477. // BufferedPaintSetAlpha() - Set alpha to given value in given rectangle
  1478. //
  1479. // hBufferedPaint - handle to buffered paint context
  1480. // prc - rectangle to set alpha in; NULL specifies entire buffer
  1481. // alpha - alpha value to set in the given rectangle
  1482. //------------------------------------------------------------------------
  1483. var
  1484. BufferedPaintSetAlpha: function(hBufferedPaint: HPAINTBUFFER; prc: PRect; alpha: Byte): HRESULT; stdcall;
  1485. {$EXTERNALSYM BufferedPaintSetAlpha}
  1486. // Macro for setting the buffer to opaque (alpha = 255)
  1487. function BufferedPaintMakeOpaque(hBufferedPaint: HPAINTBUFFER; prc: PRect): HRESULT;
  1488. {$EXTERNALSYM BufferedPaintMakeOpaque}
  1489. //------------------------------------------------------------------------
  1490. // BufferedPaintStopAllAnimations() - Stop all buffer animations for the given window
  1491. //
  1492. // hwnd - window on which to stop all animations
  1493. //------------------------------------------------------------------------
  1494. var
  1495. BufferedPaintStopAllAnimations: function(hwnd: HWND): HRESULT; stdcall;
  1496. {$EXTERNALSYM BufferedPaintStopAllAnimations}
  1497. type
  1498. HANIMATIONBUFFER = HANDLE; // handle to a buffered paint animation
  1499. {$EXTERNALSYM HANIMATIONBUFFER}
  1500. var
  1501. BeginBufferedAnimation: function(hwnd: HWND; hdcTarget: HDC; var prcTarget: TRect;
  1502. dwFormat: LongWord; pPaintParams: PBP_PAINTPARAMS; pAnimationParams: PBP_ANIMATIONPARAMS;
  1503. var phdcFrom: HDC; var phdcTo: HDC): HANIMATIONBUFFER; stdcall;
  1504. {$EXTERNALSYM BeginBufferedAnimation}
  1505. var
  1506. EndBufferedAnimation: function(hbpAnimation: HANIMATIONBUFFER; fUpdateTarget: BOOL): HRESULT; stdcall;
  1507. {$EXTERNALSYM EndBufferedAnimation}
  1508. var
  1509. BufferedPaintRenderAnimation: function(hwnd: HWND; hdcTarget: HDC): BOOL; stdcall;
  1510. {$EXTERNALSYM BufferedPaintRenderAnimation}
  1511. //----------------------------------------------------------------------------
  1512. // Tells if the DWM is running, and composition effects are possible for this
  1513. // process (themes are active).
  1514. // Roughly equivalent to "DwmIsCompositionEnabled() && IsAppthemed()"
  1515. //----------------------------------------------------------------------------
  1516. var
  1517. IsCompositionActive: function: BOOL; stdcall;
  1518. {$EXTERNALSYM IsCompositionActive}
  1519. //------------------------------------------------------------------------
  1520. // GetThemeTransitionDuration()
  1521. // - Gets the duration for the specified transition
  1522. //
  1523. // hTheme - theme data handle
  1524. // iPartId - part number
  1525. // iStateIdFrom - starting state number of part
  1526. // iStateIdTo - ending state number of part
  1527. // iPropId - property id
  1528. // pdwDuration - receives the transition duration
  1529. //------------------------------------------------------------------------
  1530. var
  1531. GetThemeTransitionDuration: function(hTheme: HTHEME; iPartId, iStateIdFrom, iStateIdTo, iPropId: Integer;
  1532. var pdwDuration: DWORD): HRESULT;
  1533. {$EXTERNALSYM GetThemeTransitionDuration}
  1534. // endif // if (_WIN32_WINNT >= 0x0600)
  1535. implementation
  1536. {$ifdef USE_SYNCOBJS}
  1537. // we can't do this due to a circular dependency between winunits-base and fcl-base
  1538. uses
  1539. SyncObjs;
  1540. {$endif}
  1541. //----------------------------------------------------------------------------------------------------------------------
  1542. const
  1543. themelib = 'uxtheme.dll';
  1544. var
  1545. ThemeLibrary: THandle;
  1546. ReferenceCount: Integer; // We have to keep track of several load/unload calls.
  1547. {$ifdef USE_SYNCOBJS}
  1548. Lock: TCriticalSection;
  1549. {$endif}
  1550. procedure FreeThemeLibrary;
  1551. begin
  1552. {$ifdef USE_SYNCOBJS}
  1553. Lock.Enter;
  1554. {$endif}
  1555. try
  1556. if ReferenceCount > 0 then
  1557. Dec(ReferenceCount);
  1558. if (ThemeLibrary <> 0) and (ReferenceCount = 0) then
  1559. begin
  1560. FreeLibrary(ThemeLibrary);
  1561. ThemeLibrary := 0;
  1562. OpenThemeData := nil;
  1563. CloseThemeData := nil;
  1564. DrawThemeBackground := nil;
  1565. DrawThemeText := nil;
  1566. GetThemeBackgroundContentRect := nil;
  1567. GetThemeBackgroundExtent := nil;
  1568. GetThemePartSize := nil;
  1569. GetThemeTextExtent := nil;
  1570. GetThemeTextMetrics := nil;
  1571. GetThemeBackgroundRegion := nil;
  1572. HitTestThemeBackground := nil;
  1573. DrawThemeEdge := nil;
  1574. DrawThemeIcon := nil;
  1575. IsThemePartDefined := nil;
  1576. IsThemeBackgroundPartiallyTransparent := nil;
  1577. GetThemeColor := nil;
  1578. GetThemeMetric := nil;
  1579. GetThemeString := nil;
  1580. GetThemeBool := nil;
  1581. GetThemeInt := nil;
  1582. GetThemeEnumValue := nil;
  1583. GetThemePosition := nil;
  1584. GetThemeFont := nil;
  1585. GetThemeRect := nil;
  1586. GetThemeMargins := nil;
  1587. GetThemeIntList := nil;
  1588. GetThemePropertyOrigin := nil;
  1589. SetWindowTheme := nil;
  1590. GetThemeFilename := nil;
  1591. GetThemeSysColor := nil;
  1592. GetThemeSysColorBrush := nil;
  1593. GetThemeSysBool := nil;
  1594. GetThemeSysSize := nil;
  1595. GetThemeSysFont := nil;
  1596. GetThemeSysString := nil;
  1597. GetThemeSysInt := nil;
  1598. IsThemeActive := nil;
  1599. IsAppThemed := nil;
  1600. GetWindowTheme := nil;
  1601. EnableThemeDialogTexture := nil;
  1602. IsThemeDialogTextureEnabled := nil;
  1603. GetThemeAppProperties := nil;
  1604. SetThemeAppProperties := nil;
  1605. GetCurrentThemeName := nil;
  1606. GetThemeDocumentationProperty := nil;
  1607. DrawThemeParentBackground := nil;
  1608. EnableTheming := nil;
  1609. OpenThemeDataEx := nil;
  1610. DrawThemeBackgroundEx := nil;
  1611. DrawThemeParentBackgroundEx := nil;
  1612. SetWindowThemeAttribute := nil;
  1613. DrawThemeTextEx := nil;
  1614. GetThemeBitmap := nil;
  1615. GetThemeStream := nil;
  1616. BufferedPaintInit := nil;
  1617. BufferedPaintUnInit := nil;
  1618. BeginBufferedPaint := nil;
  1619. EndBufferedPaint := nil;
  1620. GetBufferedPaintTargetRect := nil;
  1621. GetBufferedPaintTargetDC := nil;
  1622. GetBufferedPaintDC := nil;
  1623. GetBufferedPaintBits := nil;
  1624. BufferedPaintClear := nil;
  1625. BufferedPaintSetAlpha := nil;
  1626. BufferedPaintStopAllAnimations := nil;
  1627. BeginBufferedAnimation := nil;
  1628. EndBufferedAnimation := nil;
  1629. BufferedPaintRenderAnimation := nil;
  1630. IsCompositionActive := nil;
  1631. GetThemeTransitionDuration := nil;
  1632. BeginPanningFeedback := nil;
  1633. UpdatePanningFeedback := nil;
  1634. EndPanningFeedback := nil;
  1635. end;
  1636. finally
  1637. {$ifdef USE_SYNCOBJS}
  1638. Lock.Leave;
  1639. {$endif}
  1640. end;
  1641. end;
  1642. //----------------------------------------------------------------------------------------------------------------------
  1643. function InitThemeLibrary: Boolean;
  1644. begin
  1645. {$ifdef USE_SYNCOBJS}
  1646. Lock.Enter;
  1647. {$endif}
  1648. try
  1649. Inc(ReferenceCount);
  1650. if ThemeLibrary = 0 then
  1651. begin
  1652. ThemeLibrary := LoadLibrary(themelib);
  1653. if ThemeLibrary > 0 then
  1654. begin
  1655. // windows XP
  1656. Pointer(OpenThemeData) := GetProcAddress(ThemeLibrary, 'OpenThemeData');
  1657. Pointer(CloseThemeData) := GetProcAddress(ThemeLibrary, 'CloseThemeData');
  1658. Pointer(DrawThemeBackground) := GetProcAddress(ThemeLibrary, 'DrawThemeBackground');
  1659. Pointer(DrawThemeText) := GetProcAddress(ThemeLibrary, 'DrawThemeText');
  1660. Pointer(GetThemeBackgroundContentRect) := GetProcAddress(ThemeLibrary, 'GetThemeBackgroundContentRect');
  1661. Pointer(GetThemeBackgroundExtent) := GetProcAddress(ThemeLibrary, 'GetThemeBackgroundExtent');
  1662. Pointer(GetThemePartSize) := GetProcAddress(ThemeLibrary, 'GetThemePartSize');
  1663. Pointer(GetThemeTextExtent) := GetProcAddress(ThemeLibrary, 'GetThemeTextExtent');
  1664. Pointer(GetThemeTextMetrics) := GetProcAddress(ThemeLibrary, 'GetThemeTextMetrics');
  1665. Pointer(GetThemeBackgroundRegion) := GetProcAddress(ThemeLibrary, 'GetThemeBackgroundRegion');
  1666. Pointer(HitTestThemeBackground) := GetProcAddress(ThemeLibrary, 'HitTestThemeBackground');
  1667. Pointer(DrawThemeEdge) := GetProcAddress(ThemeLibrary, 'DrawThemeEdge');
  1668. Pointer(DrawThemeIcon) := GetProcAddress(ThemeLibrary, 'DrawThemeIcon');
  1669. Pointer(IsThemePartDefined) := GetProcAddress(ThemeLibrary, 'IsThemePartDefined');
  1670. Pointer(IsThemeBackgroundPartiallyTransparent) := GetProcAddress(ThemeLibrary, 'IsThemeBackgroundPartiallyTransparent');
  1671. Pointer(GetThemeColor) := GetProcAddress(ThemeLibrary, 'GetThemeColor');
  1672. Pointer(GetThemeMetric) := GetProcAddress(ThemeLibrary, 'GetThemeMetric');
  1673. Pointer(GetThemeString) := GetProcAddress(ThemeLibrary, 'GetThemeString');
  1674. Pointer(GetThemeBool) := GetProcAddress(ThemeLibrary, 'GetThemeBool');
  1675. Pointer(GetThemeInt) := GetProcAddress(ThemeLibrary, 'GetThemeInt');
  1676. Pointer(GetThemeEnumValue) := GetProcAddress(ThemeLibrary, 'GetThemeEnumValue');
  1677. Pointer(GetThemePosition) := GetProcAddress(ThemeLibrary, 'GetThemePosition');
  1678. Pointer(GetThemeFont) := GetProcAddress(ThemeLibrary, 'GetThemeFont');
  1679. Pointer(GetThemeRect) := GetProcAddress(ThemeLibrary, 'GetThemeRect');
  1680. Pointer(GetThemeMargins) := GetProcAddress(ThemeLibrary, 'GetThemeMargins');
  1681. Pointer(GetThemeIntList) := GetProcAddress(ThemeLibrary, 'GetThemeIntList');
  1682. Pointer(GetThemePropertyOrigin) := GetProcAddress(ThemeLibrary, 'GetThemePropertyOrigin');
  1683. Pointer(SetWindowTheme) := GetProcAddress(ThemeLibrary, 'SetWindowTheme');
  1684. Pointer(GetThemeFilename) := GetProcAddress(ThemeLibrary, 'GetThemeFilename');
  1685. Pointer(GetThemeSysColor) := GetProcAddress(ThemeLibrary, 'GetThemeSysColor');
  1686. Pointer(GetThemeSysColorBrush) := GetProcAddress(ThemeLibrary, 'GetThemeSysColorBrush');
  1687. Pointer(GetThemeSysBool) := GetProcAddress(ThemeLibrary, 'GetThemeSysBool');
  1688. Pointer(GetThemeSysSize) := GetProcAddress(ThemeLibrary, 'GetThemeSysSize');
  1689. Pointer(GetThemeSysFont) := GetProcAddress(ThemeLibrary, 'GetThemeSysFont');
  1690. Pointer(GetThemeSysString) := GetProcAddress(ThemeLibrary, 'GetThemeSysString');
  1691. Pointer(GetThemeSysInt) := GetProcAddress(ThemeLibrary, 'GetThemeSysInt');
  1692. Pointer(IsThemeActive) := GetProcAddress(ThemeLibrary, 'IsThemeActive');
  1693. Pointer(IsAppThemed) := GetProcAddress(ThemeLibrary, 'IsAppThemed');
  1694. Pointer(GetWindowTheme) := GetProcAddress(ThemeLibrary, 'GetWindowTheme');
  1695. Pointer(EnableThemeDialogTexture) := GetProcAddress(ThemeLibrary, 'EnableThemeDialogTexture');
  1696. Pointer(IsThemeDialogTextureEnabled) := GetProcAddress(ThemeLibrary, 'IsThemeDialogTextureEnabled');
  1697. Pointer(GetThemeAppProperties) := GetProcAddress(ThemeLibrary, 'GetThemeAppProperties');
  1698. Pointer(SetThemeAppProperties) := GetProcAddress(ThemeLibrary, 'SetThemeAppProperties');
  1699. Pointer(GetCurrentThemeName) := GetProcAddress(ThemeLibrary, 'GetCurrentThemeName');
  1700. Pointer(GetThemeDocumentationProperty) := GetProcAddress(ThemeLibrary, 'GetThemeDocumentationProperty');
  1701. Pointer(DrawThemeParentBackground) := GetProcAddress(ThemeLibrary, 'DrawThemeParentBackground');
  1702. Pointer(EnableTheming) := GetProcAddress(ThemeLibrary, 'EnableTheming');
  1703. // windows Vista
  1704. Pointer(OpenThemeDataEx) := GetProcAddress(ThemeLibrary, 'OpenThemeDataEx');
  1705. Pointer(DrawThemeBackgroundEx) := GetProcAddress(ThemeLibrary, 'DrawThemeBackgroundEx');
  1706. Pointer(DrawThemeParentBackgroundEx) := GetProcAddress(ThemeLibrary, 'DrawThemeParentBackgroundEx');
  1707. Pointer(SetWindowThemeAttribute) := GetProcAddress(ThemeLibrary, 'SetWindowThemeAttribute');
  1708. Pointer(DrawThemeTextEx) := GetProcAddress(ThemeLibrary, 'DrawThemeTextEx');
  1709. Pointer(GetThemeBitmap) := GetProcAddress(ThemeLibrary, 'GetThemeBitmap');
  1710. Pointer(GetThemeStream) := GetProcAddress(ThemeLibrary, 'GetThemeStream');
  1711. Pointer(BufferedPaintInit) := GetProcAddress(ThemeLibrary, 'BufferedPaintInit');
  1712. Pointer(BufferedPaintUnInit) := GetProcAddress(ThemeLibrary, 'BufferedPaintUnInit');
  1713. Pointer(BeginBufferedPaint) := GetProcAddress(ThemeLibrary, 'BeginBufferedPaint');
  1714. Pointer(EndBufferedPaint) := GetProcAddress(ThemeLibrary, 'EndBufferedPaint');
  1715. Pointer(GetBufferedPaintTargetRect) := GetProcAddress(ThemeLibrary, 'GetBufferedPaintTargetRect');
  1716. Pointer(GetBufferedPaintTargetDC) := GetProcAddress(ThemeLibrary, 'GetBufferedPaintTargetDC');
  1717. Pointer(GetBufferedPaintDC) := GetProcAddress(ThemeLibrary, 'GetBufferedPaintDC');
  1718. Pointer(GetBufferedPaintBits) := GetProcAddress(ThemeLibrary, 'GetBufferedPaintBits');
  1719. Pointer(BufferedPaintClear) := GetProcAddress(ThemeLibrary, 'BufferedPaintClear');
  1720. Pointer(BufferedPaintSetAlpha) := GetProcAddress(ThemeLibrary, 'BufferedPaintSetAlpha');
  1721. Pointer(BufferedPaintStopAllAnimations) := GetProcAddress(ThemeLibrary, 'BufferedPaintStopAllAnimations');
  1722. Pointer(BeginBufferedAnimation) := GetProcAddress(ThemeLibrary, 'BeginBufferedAnimation');
  1723. Pointer(EndBufferedAnimation) := GetProcAddress(ThemeLibrary, 'EndBufferedAnimation');
  1724. Pointer(BufferedPaintRenderAnimation) := GetProcAddress(ThemeLibrary, 'BufferedPaintRenderAnimation');
  1725. Pointer(IsCompositionActive) := GetProcAddress(ThemeLibrary, 'IsCompositionActive');
  1726. Pointer(GetThemeTransitionDuration) := GetProcAddress(ThemeLibrary, 'GetThemeTransitionDuration');
  1727. // windows 7
  1728. Pointer(BeginPanningFeedback) := GetProcAddress(ThemeLibrary, 'BeginPanningFeedback');
  1729. Pointer(UpdatePanningFeedback) := GetProcAddress(ThemeLibrary, 'UpdatePanningFeedback');
  1730. Pointer(EndPanningFeedback) := GetProcAddress(ThemeLibrary, 'EndPanningFeedback');
  1731. end;
  1732. end;
  1733. Result := ThemeLibrary > 0;
  1734. finally
  1735. {$ifdef USE_SYNCOBJS}
  1736. Lock.Leave;
  1737. {$endif}
  1738. end;
  1739. end;
  1740. //----------------------------------------------------------------------------------------------------------------------
  1741. function UseThemes: Boolean;
  1742. begin
  1743. Result := ThemeLibrary > 0;
  1744. if Result then
  1745. Result := IsAppThemed() and IsThemeActive();
  1746. end;
  1747. //----------------------------------------------------------------------------------------------------------------------
  1748. function SetWindowThemeNonClientAttributes(hwnd: HWND; dwMask: DWORD; dwAttributes: DWORD): HRESULT;
  1749. var
  1750. wta: WTA_OPTIONS;
  1751. begin
  1752. wta.dwFlags := dwAttributes;
  1753. wta.dwMask := dwMask;
  1754. Result := SetWindowThemeAttribute(hwnd, WTA_NONCLIENT, @wta, sizeof(wta));
  1755. end;
  1756. //----------------------------------------------------------------------------------------------------------------------
  1757. function BufferedPaintMakeOpaque(hBufferedPaint: HPAINTBUFFER; prc: PRect): HRESULT;
  1758. begin
  1759. Result := BufferedPaintSetAlpha(hBufferedPaint, prc, 255);
  1760. end;
  1761. //----------------------------------------------------------------------------------------------------------------------
  1762. initialization
  1763. ReferenceCount := 0;
  1764. {$ifdef USE_SYNCOBJS}
  1765. Lock := TCriticalSection.Create;
  1766. {$endif}
  1767. finalization
  1768. while ReferenceCount > 0 do
  1769. FreeThemeLibrary;
  1770. {$ifdef USE_SYNCOBJS}
  1771. Lock.Free;
  1772. {$endif}
  1773. end.