2
0

uxtheme.pp 95 KB

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