2
0

uxtheme.pp 95 KB

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