ThemeSrv.pas 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077
  1. unit ThemeSrv;
  2. //----------------------------------------------------------------------------------------------------------------------
  3. // Windows XP Theme Manager is freeware. You may freely use it in any software, including commercial software, provided
  4. // you accept the following conditions:
  5. //
  6. // 1) The software may not be included into component collections and similar compilations which are sold. If you want
  7. // to distribute this software for money then contact me first and ask for my permission.
  8. // 2) My copyright notices in the source code may not be removed or modified.
  9. // 3) If you modify and/or distribute the code to any third party then you must not veil the original author. It must
  10. // always be clearly identifiable that I, Mike Lischke, am the original author.
  11. // Although it is not required it would be a nice move to recognize my work by adding a citation to the application's
  12. // about box or a similar place.
  13. //
  14. // The original code is ThemeSrv.pas, released 03. February 2002.
  15. //
  16. // The initial developer of the original code is:
  17. // Mike Lischke ([email protected], www.soft-gems.net).
  18. //
  19. // Portions created by Mike Lischke are
  20. // (C) 2001-2005 Mike Lischke. All Rights Reserved.
  21. //----------------------------------------------------------------------------------------------------------------------
  22. //
  23. // This unit contains the implementation of TThemeServices which is a designed to manage all necessary aspects of
  24. // the Windows XP (and up) theme APIs. The component is responsible for loading and unloading of the theme DLL
  25. // and offers properties and methods to test for various aspects of the theme APIs and to ease painting of themed
  26. // window content.
  27. //
  28. // The TThemeServices class is designed to work for controls which need XP paint stuff. It does not manipulate
  29. // any VCL class (for this task TThemeManager is responsible) and can be used standalone (also as general support
  30. // tool in an application). Using the global ThemeServices function you can implicitely create and use a single
  31. // instance of the class. Theme Manager uses the same approach.
  32. //----------------------------------------------------------------------------------------------------------------------
  33. // For version information and history see ThemeMgr.pas source file.
  34. //----------------------------------------------------------------------------------------------------------------------
  35. interface
  36. uses
  37. Windows, Classes, Messages, Graphics, Controls,
  38. UxTheme, TmSchema;
  39. {$I Compilers.inc}
  40. type
  41. // These are all elements which can be themed.
  42. TThemedElement = (
  43. teButton,
  44. teClock,
  45. teComboBox,
  46. teEdit,
  47. teExplorerBar,
  48. teHeader,
  49. teListView,
  50. teMenu,
  51. tePage,
  52. teProgress,
  53. teRebar,
  54. teScrollBar,
  55. teSpin,
  56. teStartPanel,
  57. teStatus,
  58. teTab,
  59. teTaskBand,
  60. teTaskBar,
  61. teToolBar,
  62. teToolTip,
  63. teTrackBar,
  64. teTrayNotify,
  65. teTreeview,
  66. teWindow
  67. );
  68. // 'Button' theme data
  69. TThemedButton = (
  70. tbButtonDontCare,
  71. tbButtonRoot, // The root part of each element is sometimes used for special painting and does not
  72. // belong to a certain state.
  73. tbPushButtonNormal, tbPushButtonHot, tbPushButtonPressed, tbPushButtonDisabled, tbPushButtonDefaulted,
  74. tbRadioButtonUncheckedNormal, tbRadioButtonUncheckedHot, tbRadioButtonUncheckedPressed, tbRadioButtonUncheckedDisabled,
  75. tbRadioButtonCheckedNormal, tbRadioButtonCheckedHot, tbRadioButtonCheckedPressed, tbRadioButtonCheckedDisabled,
  76. tbCheckBoxUncheckedNormal, tbCheckBoxUncheckedHot, tbCheckBoxUncheckedPressed, tbCheckBoxUncheckedDisabled,
  77. tbCheckBoxCheckedNormal, tbCheckBoxCheckedHot, tbCheckBoxCheckedPressed, tbCheckBoxCheckedDisabled,
  78. tbCheckBoxMixedNormal, tbCheckBoxMixedHot, tbCheckBoxMixedPressed, tbCheckBoxMixedDisabled,
  79. tbGroupBoxNormal, tbGroupBoxDisabled,
  80. tbUserButton
  81. );
  82. // 'Clock' theme data
  83. TThemedClock = (
  84. tcClockDontCare,
  85. tcClockRoot,
  86. tcTimeNormal
  87. );
  88. // 'ComboBox' theme data
  89. TThemedComboBox = (
  90. tcComboBoxDontCare,
  91. tcComboBoxRoot,
  92. tcDropDownButtonNormal, tcDropDownButtonHot, tcDropDownButtonPressed, tcDropDownButtonDisabled
  93. );
  94. // 'Edit' theme data
  95. TThemedEdit = (
  96. teEditDontCare,
  97. teEditRoot,
  98. teEditTextNormal, teEditTextHot, teEditTextSelected, teEditTextDisabled, teEditTextFocused, teEditTextReadOnly, teEditTextAssist,
  99. teEditCaret
  100. );
  101. // 'ExplorerBar' theme data
  102. TThemedExplorerBar = (
  103. tebExplorerBarDontCare,
  104. tebExplorerBarRoot,
  105. tebHeaderBackgroundNormal, tebHeaderBackgroundHot, tebHeaderBackgroundPressed,
  106. tebHeaderCloseNormal, tebHeaderCloseHot, tebHeaderClosePressed,
  107. tebHeaderPinNormal, tebHeaderPinHot, tebHeaderPinPressed,
  108. tebHeaderPinSelectedNormal, tebHeaderPinSelectedHot, tebHeaderPinSelectedPressed,
  109. tebIEBarMenuNormal, tebIEBarMenuHot, tebIEBarMenuPressed,
  110. tebNormalGroupBackground,
  111. tebNormalGroupCollapseNormal, tebNormalGroupCollapseHot, tebNormalGroupCollapsePressed,
  112. tebNormalGroupExpandNormal, tebNormalGroupExpandHot, tebNormalGroupExpandPressed,
  113. tebNormalGroupHead,
  114. tebSpecialGroupBackground,
  115. tebSpecialGroupCollapseSpecial, tebSpecialGroupCollapseHot, tebSpecialGroupCollapsePressed,
  116. tebSpecialGroupExpandSpecial, tebSpecialGroupExpandHot, tebSpecialGroupExpandPressed,
  117. tebSpecialGroupHead
  118. );
  119. // 'Header' theme data
  120. TThemedHeader = (
  121. thHeaderDontCare,
  122. thHeaderRoot,
  123. thHeaderItemNormal, thHeaderItemHot, thHeaderItemPressed,
  124. thHeaderItemLeftNormal, thHeaderItemLeftHot, thHeaderItemLeftPressed,
  125. thHeaderItemRightNormal, thHeaderItemRightHot, thHeaderItemRightPressed,
  126. thHeaderSortArrowSortedUp, thHeaderSortArrowSortedDown
  127. );
  128. // 'ListView' theme data
  129. TThemedListview = (
  130. tlListviewDontCare,
  131. tlListviewRoot,
  132. tlListItemNormal, tlListItemHot, tlListItemSelected, tlListItemDisabled, tlListItemSelectedNotFocus,
  133. tlListGroup,
  134. tlListDetail,
  135. tlListSortDetail,
  136. tlEmptyText
  137. );
  138. // 'Menu' theme data
  139. TThemedMenu = (
  140. tmMenuDontCare,
  141. tmMenuRoot,
  142. tmMenuItemNormal, tmMenuItemSelected, tmMenuItemDemoted,
  143. tmMenuDropDown,
  144. tmMenuBarItem,
  145. tmMenuBarDropDown,
  146. tmChevron,
  147. tmSeparator
  148. );
  149. // 'Page' theme data
  150. TThemedPage = (
  151. tpPageDontCare,
  152. tpPageRoot,
  153. tpUpNormal, tpUpHot, tpUpPressed, tpUpDisabled,
  154. tpDownNormal, tpDownHot, tpDownPressed, tpDownDisabled,
  155. tpUpHorzNormal, tpUpHorzHot, tpUpHorzPressed, tpUpHorzDisabled,
  156. tpDownHorzNormal, tpDownHorzHot, tpDownHorzPressed, tpDownHorzDisabled
  157. );
  158. // 'Progress' theme data
  159. TThemedProgress = (
  160. tpProgressDontCare,
  161. tpProgressRoot,
  162. tpBar,
  163. tpBarVert,
  164. tpChunk,
  165. tpChunkVert
  166. );
  167. // 'Rebar' theme data
  168. TThemedRebar = (
  169. trRebarDontCare,
  170. trRebarRoot,
  171. trGripper,
  172. trGripperVert,
  173. trBandNormal, trBandHot, trBandPressed, trBandDisabled, trBandChecked, trBandHotChecked,
  174. trChevronNormal, trChevronHot, trChevronPressed, trChevronDisabled,
  175. trChevronVertNormal, trChevronVertHot, trChevronVertPressed, trChevronVertDisabled
  176. );
  177. // 'ScrollBar' theme data
  178. TThemedScrollBar = (
  179. tsScrollBarDontCare,
  180. tsScrollBarRoot,
  181. tsArrowBtnUpNormal, tsArrowBtnUpHot, tsArrowBtnUpPressed, tsArrowBtnUpDisabled,
  182. tsArrowBtnDownNormal, tsArrowBtnDownHot, tsArrowBtnDownPressed, tsArrowBtnDownDisabled,
  183. tsArrowBtnLeftNormal, tsArrowBtnLeftHot, tsArrowBtnLeftPressed, tsArrowBtnLeftDisabled,
  184. tsArrowBtnRightNormal, tsArrowBtnRightHot, tsArrowBtnRightPressed, tsArrowBtnRightDisabled,
  185. tsThumbBtnHorzNormal, tsThumbBtnHorzHot, tsThumbBtnHorzPressed, tsThumbBtnHorzDisabled,
  186. tsThumbBtnVertNormal, tsThumbBtnVertHot, tsThumbBtnVertPressed, tsThumbBtnVertDisabled,
  187. tsLowerTrackHorzNormal, tsLowerTrackHorzHot, tsLowerTrackHorzPressed, tsLowerTrackHorzDisabled,
  188. tsUpperTrackHorzNormal, tsUpperTrackHorzHot, tsUpperTrackHorzPressed, tsUpperTrackHorzDisabled,
  189. tsLowerTrackVertNormal, tsLowerTrackVertHot, tsLowerTrackVertPressed, tsLowerTrackVertDisabled,
  190. tsUpperTrackVertNormal, tsUpperTrackVertHot, tsUpperTrackVertPressed, tsUpperTrackVertDisabled,
  191. tsGripperHorzNormal, tsGripperHorzHot, tsGripperHorzPressed, tsGripperHorzDisabled,
  192. tsGripperVertNormal, tsGripperVertHot, tsGripperVertPressed, tsGripperVertDisabled,
  193. tsSizeBoxRightAlign, tsSizeBoxLeftAlign
  194. );
  195. // 'Spin' theme data
  196. TThemedSpin = (
  197. tsSpinDontCare,
  198. tsSpinRoot,
  199. tsUpNormal, tsUpHot, tsUpPressed, tsUpDisabled,
  200. tsDownNormal, tsDownHot, tsDownPressed, tsDownDisabled,
  201. tsUpHorzNormal, tsUpHorzHot, tsUpHorzPressed, tsUpHorzDisabled,
  202. tsDownHorzNormal, tsDownHorzHot, tsDownHorzPressed, tsDownHorzDisabled
  203. );
  204. // 'StartPanel' theme data
  205. TThemedStartPanel = (
  206. tspStartPanelDontCare,
  207. tspStartPanelRoot,
  208. tspUserPane,
  209. tspMorePrograms,
  210. tspMoreProgramsArrowNormal, tspMoreProgramsArrowHot, tspMoreProgramsArrowPressed,
  211. tspProgList,
  212. tspProgListSeparator,
  213. tspPlacesList,
  214. tspPlacesListSeparator,
  215. tspLogOff,
  216. tspLogOffButtonsNormal, tspLogOffButtonsHot, tspLogOffButtonsPressed,
  217. tspUserPicture,
  218. tspPreview
  219. );
  220. // 'Status' theme data
  221. TThemedStatus = (
  222. tsStatusDontCare,
  223. tsStatusRoot,
  224. tsPane,
  225. tsGripperPane,
  226. tsGripper
  227. );
  228. // 'Tab' theme data
  229. TThemedTab = (
  230. ttTabDontCare,
  231. ttTabRoot,
  232. ttTabItemNormal, ttTabItemHot, ttTabItemSelected, ttTabItemDisabled, ttTabItemFocused,
  233. ttTabItemLeftEdgeNormal, ttTabItemLeftEdgeHot, ttTabItemLeftEdgeSelected, ttTabItemLeftEdgeDisabled, ttTabItemLeftEdgeFocused,
  234. ttTabItemRightEdgeNormal, ttTabItemRightEdgeHot, ttTabItemRightEdgeSelected, ttTabItemRightEdgeDisabled, ttTabItemRightEdgeFocused,
  235. ttTabItemBothEdgeNormal, ttTabItemBothEdgeHot, ttTabItemBothEdgeSelected, ttTabItemBothEdgeDisabled, ttTabItemBothEdgeFocused,
  236. ttTopTabItemNormal, ttTopTabItemHot, ttTopTabItemSelected, ttTopTabItemDisabled, ttTopTabItemFocused,
  237. ttTopTabItemLeftEdgeNormal, ttTopTabItemLeftEdgeHot, ttTopTabItemLeftEdgeSelected, ttTopTabItemLeftEdgeDisabled, ttTopTabItemLeftEdgeFocused,
  238. ttTopTabItemRightEdgeNormal, ttTopTabItemRightEdgeHot, ttTopTabItemRightEdgeSelected, ttTopTabItemRightEdgeDisabled, ttTopTabItemRightEdgeFocused,
  239. ttTopTabItemBothEdgeNormal, ttTopTabItemBothEdgeHot, ttTopTabItemBothEdgeSelected, ttTopTabItemBothEdgeDisabled, ttTopTabItemBothEdgeFocused,
  240. ttPane,
  241. ttBody
  242. );
  243. // 'TaskBand' theme data
  244. TThemedTaskBand = (
  245. ttbTaskBandDontCare,
  246. ttbTaskBandRoot,
  247. ttbGroupCount,
  248. ttbFlashButton,
  249. ttpFlashButtonGroupMenu
  250. );
  251. // 'TaskBar' theme data
  252. TThemedTaskBar = (
  253. ttTaskBarDontCare,
  254. ttTaskBarRoot,
  255. ttbTimeNormal
  256. );
  257. // 'ToolBar' theme data
  258. TThemedToolBar = (
  259. ttbToolBarDontCare,
  260. ttbToolBarRoot,
  261. ttbButtonNormal, ttbButtonHot, ttbButtonPressed, ttbButtonDisabled, ttbButtonChecked, ttbButtonCheckedHot,
  262. ttbDropDownButtonNormal, ttbDropDownButtonHot, ttbDropDownButtonPressed, ttbDropDownButtonDisabled, ttbDropDownButtonChecked, ttbDropDownButtonCheckedHot,
  263. ttbSplitButtonNormal, ttbSplitButtonHot, ttbSplitButtonPressed, ttbSplitButtonDisabled, ttbSplitButtonChecked, ttbSplitButtonCheckedHot,
  264. ttbSplitButtonDropDownNormal, ttbSplitButtonDropDownHot, ttbSplitButtonDropDownPressed, ttbSplitButtonDropDownDisabled, ttbSplitButtonDropDownChecked, ttbSplitButtonDropDownCheckedHot,
  265. ttbSeparatorNormal, ttbSeparatorHot, ttbSeparatorPressed, ttbSeparatorDisabled, ttbSeparatorChecked, ttbSeparatorCheckedHot,
  266. ttbSeparatorVertNormal, ttbSeparatorVertHot, ttbSeparatorVertPressed, ttbSeparatorVertDisabled, ttbSeparatorVertChecked, ttbSeparatorVertCheckedHot
  267. );
  268. // 'ToolTip' theme data
  269. TThemedToolTip = (
  270. tttToolTipDontCare,
  271. tttToolTipRoot,
  272. tttStandardNormal, tttStandardLink,
  273. tttStandardTitleNormal, tttStandardTitleLink,
  274. tttBaloonNormal, tttBaloonLink,
  275. tttBaloonTitleNormal, tttBaloonTitleLink,
  276. tttCloseNormal, tttCloseHot, tttClosePressed
  277. );
  278. // 'TrackBar' theme data
  279. TThemedTrackBar = (
  280. ttbTrackBarDontCare,
  281. ttbTrackBarRoot,
  282. ttbTrack,
  283. ttbTrackVert,
  284. ttbThumbNormal, ttbThumbHot, ttbThumbPressed, ttbThumbFocused, ttbThumbDisabled,
  285. ttbThumbBottomNormal, ttbThumbBottomHot, ttbThumbBottomPressed, ttbThumbBottomFocused, ttbThumbBottomDisabled,
  286. ttbThumbTopNormal, ttbThumbTopHot, ttbThumbTopPressed, ttbThumbTopFocused, ttbThumbTopDisabled,
  287. ttbThumbVertNormal, ttbThumbVertHot, ttbThumbVertPressed, ttbThumbVertFocused, ttbThumbVertDisabled,
  288. ttbThumbLeftNormal, ttbThumbLeftHot, ttbThumbLeftPressed, ttbThumbLeftFocused, ttbThumbLeftDisabled,
  289. ttbThumbRightNormal, ttbThumbRightHot, ttbThumbRightPressed, ttbThumbRightFocused, ttbThumbRightDisabled,
  290. ttbThumbTics,
  291. ttbThumbTicsVert
  292. );
  293. // 'TrayNotify' theme data
  294. TThemedTrayNotify = (
  295. ttnTrayNotifyDontCare,
  296. ttnTrayNotifyRoot,
  297. ttnBackground,
  298. ttnAnimBackground
  299. );
  300. // 'Treeview' theme data
  301. TThemedTreeview = (
  302. ttTreeviewDontCare,
  303. ttTreeviewRoot,
  304. ttItemNormal, ttItemHot, ttItemSelected, ttItemDisabled, ttItemSelectedNotFocus,
  305. ttGlyphClosed, ttGlyphOpened,
  306. ttBranch
  307. );
  308. // 'Window' theme data
  309. TThemedWindow = (
  310. twWindowDontCare,
  311. twWindowRoot,
  312. twCaptionActive, twCaptionInactive, twCaptionDisabled,
  313. twSmallCaptionActive, twSmallCaptionInactive, twSmallCaptionDisabled,
  314. twMinCaptionActive, twMinCaptionInactive, twMinCaptionDisabled,
  315. twSmallMinCaptionActive, twSmallMinCaptionInactive, twSmallMinCaptionDisabled,
  316. twMaxCaptionActive, twMaxCaptionInactive, twMaxCaptionDisabled,
  317. twSmallMaxCaptionActive, twSmallMaxCaptionInactive, twSmallMaxCaptionDisabled,
  318. twFrameLeftActive, twFrameLeftInactive,
  319. twFrameRightActive, twFrameRightInactive,
  320. twFrameBottomActive, twFrameBottomInactive,
  321. twSmallFrameLeftActive, twSmallFrameLeftInactive,
  322. twSmallFrameRightActive, twSmallFrameRightInactive,
  323. twSmallFrameBottomActive, twSmallFrameBottomInactive,
  324. twSysButtonNormal, twSysButtonHot, twSysButtonPushed, twSysButtonDisabled, twSysButtonInactive,
  325. twMDISysButtonNormal, twMDISysButtonHot, twMDISysButtonPushed, twMDISysButtonDisabled, twMDISysButtonInactive,
  326. twMinButtonNormal, twMinButtonHot, twMinButtonPushed, twMinButtonDisabled, twMinButtonInactive,
  327. twMDIMinButtonNormal, twMDIMinButtonHot, twMDIMinButtonPushed, twMDIMinButtonDisabled, twMDIMinButtonInactive,
  328. twMaxButtonNormal, twMaxButtonHot, twMaxButtonPushed, twMaxButtonDisabled, twMaxButtonInactive,
  329. twCloseButtonNormal, twCloseButtonHot, twCloseButtonPushed, twCloseButtonDisabled, twCloseButtonInactive,
  330. twSmallCloseButtonNormal, twSmallCloseButtonHot, twSmallCloseButtonPushed, twSmallCloseButtonDisabled, twSmallCloseButtonInactive,
  331. twMDICloseButtonNormal, twMDICloseButtonHot, twMDICloseButtonPushed, twMDICloseButtonDisabled, twMDICloseButtonInactive,
  332. twRestoreButtonNormal, twRestoreButtonHot, twRestoreButtonPushed, twRestoreButtonDisabled, twRestoreButtonInactive,
  333. twMDIRestoreButtonNormal, twMDIRestoreButtonHot, twMDIRestoreButtonPushed, twMDIRestoreButtonDisabled, twMDIRestoreButtonInactive,
  334. twHelpButtonNormal, twHelpButtonHot, twHelpButtonPushed, twHelpButtonDisabled, twHelpButtonInactive,
  335. twMDIHelpButtonNormal, twMDIHelpButtonHot, twMDIHelpButtonPushed, twMDIHelpButtonDisabled, twMDIHelpButtonInactive,
  336. twHorzScrollNormal, twHorzScrollHot, twHorzScrollPushed, twHorzScrollDisabled,
  337. twHorzThumbNormal, twHorzThumbHot, twHorzThumbPushed, twHorzThumbDisabled,
  338. twVertScrollNormal, twVertScrollHot, twVertScrollPushed, twVertScrollDisabled,
  339. twVertThumbNormal, twVertThumbHot, twVertThumbPushed, twVertThumbDisabled,
  340. twDialog,
  341. twCaptionSizingTemplate,
  342. twSmallCaptionSizingTemplate,
  343. twFrameLeftSizingTemplate,
  344. twSmallFrameLeftSizingTemplate,
  345. twFrameRightSizingTemplate,
  346. twSmallFrameRightSizingTemplate,
  347. twFrameBottomSizingTemplate,
  348. twSmallFrameBottomSizingTemplate
  349. );
  350. TThemeData = array[TThemedElement] of HTHEME;
  351. PThemedElementDetails = ^TThemedElementDetails;
  352. TThemedElementDetails = record
  353. Element: TThemedElement;
  354. Part,
  355. State: Integer;
  356. end;
  357. // TThemeServices is a small foot print class to provide the user with pure Windows XP theme related abilities like
  358. // painting elements and text or retrieving certain info.
  359. TThemeServices = class(TObject)
  360. private
  361. FThemesAvailable,
  362. FUseThemes,
  363. FControlsEnabled: Boolean;
  364. FWindowHandle: HWND;
  365. FDefWindowProc,
  366. FObjectInstance: Pointer;
  367. FThemeData: TThemeData; // Holds a list of theme data handles.
  368. FOnThemeChange: TNotifyEvent; // Called when the current window theme has changed.
  369. function GetTheme(Element: TThemedElement): HTHEME;
  370. function GetThemesEnabled: Boolean;
  371. procedure WindowProc(var Message: TMessage);
  372. protected
  373. procedure DoOnThemeChange; virtual;
  374. procedure UnloadThemeData;
  375. public
  376. constructor Create(ClientWindow: HWND);
  377. destructor Destroy; override;
  378. function GetElementDetails(Detail: TThemedButton): TThemedElementDetails; overload;
  379. function GetElementDetails(Detail: TThemedClock): TThemedElementDetails; overload;
  380. function GetElementDetails(Detail: TThemedComboBox): TThemedElementDetails; overload;
  381. function GetElementDetails(Detail: TThemedEdit): TThemedElementDetails; overload;
  382. function GetElementDetails(Detail: TThemedExplorerBar): TThemedElementDetails; overload;
  383. function GetElementDetails(Detail: TThemedHeader): TThemedElementDetails; overload;
  384. function GetElementDetails(Detail: TThemedListView): TThemedElementDetails; overload;
  385. function GetElementDetails(Detail: TThemedMenu): TThemedElementDetails; overload;
  386. function GetElementDetails(Detail: TThemedPage): TThemedElementDetails; overload;
  387. function GetElementDetails(Detail: TThemedProgress): TThemedElementDetails; overload;
  388. function GetElementDetails(Detail: TThemedRebar): TThemedElementDetails; overload;
  389. function GetElementDetails(Detail: TThemedScrollBar): TThemedElementDetails; overload;
  390. function GetElementDetails(Detail: TThemedSpin): TThemedElementDetails; overload;
  391. function GetElementDetails(Detail: TThemedStartPanel): TThemedElementDetails; overload;
  392. function GetElementDetails(Detail: TThemedStatus): TThemedElementDetails; overload;
  393. function GetElementDetails(Detail: TThemedTab): TThemedElementDetails; overload;
  394. function GetElementDetails(Detail: TThemedTaskBand): TThemedElementDetails; overload;
  395. function GetElementDetails(Detail: TThemedTaskBar): TThemedElementDetails; overload;
  396. function GetElementDetails(Detail: TThemedToolBar): TThemedElementDetails; overload;
  397. function GetElementDetails(Detail: TThemedToolTip): TThemedElementDetails; overload;
  398. function GetElementDetails(Detail: TThemedTrackBar): TThemedElementDetails; overload;
  399. function GetElementDetails(Detail: TThemedTrayNotify): TThemedElementDetails; overload;
  400. function GetElementDetails(Detail: TThemedTreeview): TThemedElementDetails; overload;
  401. function GetElementDetails(Detail: TThemedWindow): TThemedElementDetails; overload;
  402. function ColorToRGB(Color: TColor; Details: PThemedElementDetails = nil): COLORREF;
  403. function ContentRect(DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect;
  404. procedure DrawEdge(DC: HDC; Details: TThemedElementDetails; const R: TRect; Edge, Flags: Cardinal;
  405. ContentRect: PRect = nil);
  406. procedure DrawElement(DC: HDC; Details: TThemedElementDetails; const R: TRect; ClipRect: PRect = nil);
  407. procedure DrawIcon(DC: HDC; Details: TThemedElementDetails; const R: TRect; himl: HIMAGELIST; Index: Integer);
  408. procedure DrawParentBackground(Window: HWND; Target: HDC; Details: PThemedElementDetails; OnlyIfTransparent: Boolean;
  409. Bounds: PRect = nil);
  410. procedure DrawText(DC: HDC; Details: TThemedElementDetails; const S: WideString; R: TRect; Flags, Flags2: Cardinal);
  411. function HasTransparentParts(Details: TThemedElementDetails): Boolean;
  412. procedure PaintBorder(Control: TWinControl; EraseLRCorner: Boolean);
  413. procedure UpdateThemes;
  414. // MP
  415. function GetColor(Element: TThemedElement; PartId: Integer; StateId: Integer;
  416. PropId: Integer): TColor;
  417. property ClientWindow: HWND read FWindowHandle;
  418. property Theme[Element: TThemedElement]: HTHEME read GetTheme;
  419. property ThemesAvailable: Boolean read FThemesAvailable;
  420. property ThemesEnabled: Boolean read GetThemesEnabled;
  421. property OnThemeChange: TNotifyEvent read FOnThemeChange write FOnThemeChange;
  422. end;
  423. function ThemeServices: TThemeServices;
  424. //----------------------------------------------------------------------------------------------------------------------
  425. implementation
  426. uses
  427. Forms, // We need the application window to get notified about theme changes.
  428. SysUtils, ComCtrls;
  429. const
  430. // Do not modify the copyright in any way! Usage of this unit is prohibited without the copyright notice
  431. // in the compiled binary file.
  432. Copyright: string = 'Theme manager © 2001-2005 Mike Lischke';
  433. ThemeDataNames: array[TThemedElement] of PWideChar = (
  434. 'button', // teButton
  435. 'clock', // teClock
  436. 'combobox', // teComboBox
  437. 'edit', // teEdit
  438. 'explorerbar', // teExplorerBar
  439. 'header', // teHeader
  440. 'listview', // teListView
  441. 'menu', // teMenu
  442. 'page', // tePage
  443. 'progress', // teProgress
  444. 'rebar', // teRebar
  445. 'scrollbar', // teScrollBar
  446. 'spin', // teSpin
  447. 'startpanel', // teStartPanel
  448. 'status', // teStatus
  449. 'tab', // teTab
  450. 'taskband', // teTaskBand
  451. 'taskbar', // teTaskBar
  452. 'toolbar', // teToolBar
  453. 'tooltip', // teToolTip
  454. 'trackbar', // teTrackBar
  455. 'traynotify', // teTrayNotify
  456. 'treeview', // teTreeview
  457. 'window' // teWindow
  458. );
  459. var
  460. InternalThemeServices: TThemeServices;
  461. //----------------------------------------------------------------------------------------------------------------------
  462. function ThemeServices: TThemeServices;
  463. begin
  464. if InternalThemeServices = nil then
  465. InternalThemeServices := TThemeServices.Create(Application.Handle);
  466. Result := InternalThemeServices;
  467. end;
  468. //----------------- TThemeServices -------------------------------------------------------------------------------------
  469. constructor TThemeServices.Create(ClientWindow: HWND);
  470. begin
  471. FWindowHandle := ClientWindow;
  472. if FWindowHandle <> 0 then
  473. begin
  474. // If a window handle is given then subclass the window to get notified about theme changes.
  475. {$ifdef COMPILER_6_UP}
  476. FObjectInstance := Classes.MakeObjectInstance(WindowProc);
  477. {$else}
  478. FObjectInstance := MakeObjectInstance(WindowProc);
  479. {$endif COMPILER_6_UP}
  480. FDefWindowProc := Pointer(GetWindowLong(FWindowHandle, GWL_WNDPROC));
  481. SetWindowLong(FWindowHandle, GWL_WNDPROC, Integer(FObjectInstance));
  482. end;
  483. FThemesAvailable := InitThemeLibrary;
  484. UpdateThemes;
  485. end;
  486. //----------------------------------------------------------------------------------------------------------------------
  487. destructor TThemeServices.Destroy;
  488. begin
  489. if Assigned(FObjectInstance) then
  490. begin
  491. SetWindowLong(FWindowHandle, GWL_WNDPROC, Integer(FDefWindowProc));
  492. {$ifdef COMPILER_6_UP}
  493. Classes.FreeObjectInstance(FObjectInstance);
  494. {$else}
  495. FreeObjectInstance(FObjectInstance);
  496. {$endif COMPILER_6_UP}
  497. end;
  498. UnloadThemeData;
  499. FreeThemeLibrary;
  500. inherited;
  501. end;
  502. //----------------------------------------------------------------------------------------------------------------------
  503. function TThemeServices.GetTheme(Element: TThemedElement): HTHEME;
  504. // Returns the theme data handle for the given element. The theme is opened if not yet done.
  505. begin
  506. if FUseThemes and (FThemeData[Element] = 0) then
  507. begin
  508. FThemeData[Element] := OpenThemeData(FWindowHandle, ThemeDataNames[Element]);
  509. end;
  510. Result := FThemeData[Element];
  511. end;
  512. //----------------------------------------------------------------------------------------------------------------------
  513. function TThemeServices.GetThemesEnabled: Boolean;
  514. begin
  515. Result := FThemesAvailable and FUseThemes and FControlsEnabled;
  516. end;
  517. //----------------------------------------------------------------------------------------------------------------------
  518. procedure TThemeServices.WindowProc(var Message: TMessage);
  519. begin
  520. case Message.Msg of
  521. WM_THEMECHANGED:
  522. begin
  523. // This message only appears if the services serve a particular window. If the services are part of some other theme
  524. // management structure (without an own window, e.g. in a TThemeManager class) then this structure is responsible to
  525. // call UpdateThemes explicitely.
  526. UpdateThemes;
  527. DoOnThemeChange;
  528. end;
  529. WM_DESTROY:
  530. begin
  531. // If we are connected to a window then we have to listen to its destruction.
  532. SetWindowLong(FWindowHandle, GWL_WNDPROC, Integer(FDefWindowProc));
  533. {$ifdef COMPILER_6_UP}
  534. Classes.FreeObjectInstance(FObjectInstance);
  535. {$else}
  536. FreeObjectInstance(FObjectInstance);
  537. {$endif COMPILER_6_UP}
  538. FObjectInstance := nil;
  539. end;
  540. end;
  541. with Message do
  542. Result := CallWindowProc(FDefWindowProc, FWindowHandle, Msg, WParam, LParam);
  543. end;
  544. //----------------------------------------------------------------------------------------------------------------------
  545. procedure TThemeServices.DoOnThemeChange;
  546. begin
  547. if Assigned(FOnThemeChange) then
  548. FOnThemeChange(Self);
  549. end;
  550. //----------------------------------------------------------------------------------------------------------------------
  551. procedure TThemeServices.UnloadThemeData;
  552. // Closes all opened theme data handles and frees the theme records.
  553. var
  554. Entry: TThemedElement;
  555. begin
  556. if (FWindowHandle = 0) or IsWindow(FWindowHandle) then
  557. begin
  558. for Entry := Low(TThemeData) to High(TThemeData) do
  559. if FThemeData[Entry] <> 0 then
  560. begin
  561. CloseThemeData(FThemeData[Entry]);
  562. FThemeData[Entry] := 0;
  563. end;
  564. end;
  565. end;
  566. //----------------------------------------------------------------------------------------------------------------------
  567. function TThemeServices.GetElementDetails(Detail: TThemedButton): TThemedElementDetails;
  568. var
  569. Base: Integer;
  570. begin
  571. Result.Element := teButton;
  572. with Result do
  573. begin
  574. case Detail of
  575. tbPushButtonNormal..tbPushButtonDefaulted:
  576. begin
  577. Part := BP_PUSHBUTTON;
  578. Base := Ord(tbPushButtonNormal);
  579. end;
  580. tbRadioButtonUncheckedNormal..tbRadioButtonCheckedDisabled:
  581. begin
  582. Part := BP_RADIOBUTTON;
  583. Base := Ord(tbRadioButtonUncheckedNormal);
  584. end;
  585. tbCheckBoxUncheckedNormal..tbCheckBoxMixedDisabled:
  586. begin
  587. Part := BP_CHECKBOX;
  588. Base := Ord(tbCheckBoxUncheckedNormal);
  589. end;
  590. tbGroupBoxNormal..tbGroupBoxDisabled:
  591. begin
  592. Part := BP_GROUPBOX;
  593. Base := Ord(tbGroupBoxNormal);
  594. end;
  595. tbUserButton:
  596. begin
  597. Part := BP_USERBUTTON;
  598. Base := Ord(tbUserButton);
  599. end;
  600. else
  601. Part := 0;
  602. Base := 0;
  603. end;
  604. State := Ord(Detail) - Base + 1;
  605. end;
  606. end;
  607. //----------------------------------------------------------------------------------------------------------------------
  608. function TThemeServices.GetElementDetails(Detail: TThemedClock): TThemedElementDetails;
  609. var
  610. Base: Integer;
  611. begin
  612. Result.Element := teClock;
  613. with Result do
  614. begin
  615. case Detail of
  616. tcTimeNormal:
  617. begin
  618. Part := CLP_TIME;
  619. Base := Ord(tcTimeNormal);
  620. end;
  621. else
  622. Part := 0;
  623. Base := 0;
  624. end;
  625. State := Ord(Detail) - Base + 1;
  626. end;
  627. end;
  628. //----------------------------------------------------------------------------------------------------------------------
  629. function TThemeServices.GetElementDetails(Detail: TThemedComboBox): TThemedElementDetails;
  630. var
  631. Base: Integer;
  632. begin
  633. Result.Element := teComboBox;
  634. with Result do
  635. begin
  636. case Detail of
  637. tcDropDownButtonNormal..tcDropDownButtonDisabled:
  638. begin
  639. Part := CP_DROPDOWNBUTTON;
  640. Base := Ord(tcDropDownButtonNormal);
  641. end;
  642. else
  643. Part := 0;
  644. Base := 0;
  645. end;
  646. State := Ord(Detail) - Base + 1;
  647. end;
  648. end;
  649. //----------------------------------------------------------------------------------------------------------------------
  650. function TThemeServices.GetElementDetails(Detail: TThemedEdit): TThemedElementDetails;
  651. var
  652. Base: Integer;
  653. begin
  654. Result.Element := teEdit;
  655. with Result do
  656. begin
  657. case Detail of
  658. teEditTextNormal..teEditTextAssist:
  659. begin
  660. Part := EP_EDITTEXT;
  661. Base := Ord(teEditTextNormal);
  662. end;
  663. teEditCaret:
  664. begin
  665. Part := EP_CARET;
  666. Base := Ord(teEditCaret);
  667. end;
  668. else
  669. Part := 0;
  670. Base := 0;
  671. end;
  672. State := Ord(Detail) - Base + 1;
  673. end;
  674. end;
  675. //----------------------------------------------------------------------------------------------------------------------
  676. function TThemeServices.GetElementDetails(Detail: TThemedExplorerBar): TThemedElementDetails;
  677. var
  678. Base: Integer;
  679. begin
  680. Result.Element := teExplorerBar;
  681. with Result do
  682. begin
  683. case Detail of
  684. tebHeaderBackgroundNormal..tebHeaderBackgroundPressed:
  685. begin
  686. Part := EBP_HEADERBACKGROUND;
  687. Base := Ord(tebHeaderBackgroundNormal);
  688. end;
  689. tebHeaderCloseNormal..tebHeaderClosePressed:
  690. begin
  691. Part := EBP_HEADERCLOSE;
  692. Base := Ord(tebHeaderCloseNormal);
  693. end;
  694. tebHeaderPinNormal..tebHeaderPinSelectedPressed:
  695. begin
  696. Part := EBP_HEADERPIN;
  697. Base := Ord(tebHeaderPinSelectedNormal);
  698. end;
  699. tebIEBarMenuNormal..tebIEBarMenuPressed:
  700. begin
  701. Part := EBP_IEBARMENU;
  702. Base := Ord(tebIEBarMenuNormal);
  703. end;
  704. tebNormalGroupBackground:
  705. begin
  706. Part := EBP_NORMALGROUPBACKGROUND;
  707. Base := Ord(tebNormalGroupBackground);
  708. end;
  709. tebNormalGroupCollapseNormal..tebNormalGroupCollapsePressed:
  710. begin
  711. Part := EBP_NORMALGROUPCOLLAPSE;
  712. Base := Ord(tebNormalGroupCollapseNormal);
  713. end;
  714. tebNormalGroupExpandNormal..tebNormalGroupExpandPressed:
  715. begin
  716. Part := EBP_NORMALGROUPEXPAND;
  717. Base := Ord(tebNormalGroupExpandNormal);
  718. end;
  719. tebNormalGroupHead:
  720. begin
  721. Part := EBP_NORMALGROUPHEAD;
  722. Base := Ord(tebNormalGroupHead);
  723. end;
  724. tebSpecialGroupBackground:
  725. begin
  726. Part := EBP_SPECIALGROUPBACKGROUND;
  727. Base := Ord(tebSpecialGroupBackground);
  728. end;
  729. tebSpecialGroupCollapseSpecial..tebSpecialGroupCollapsePressed:
  730. begin
  731. Part := EBP_SPECIALGROUPCOLLAPSE;
  732. Base := Ord(tebSpecialGroupCollapseSpecial);
  733. end;
  734. tebSpecialGroupExpandSpecial..tebSpecialGroupExpandPressed:
  735. begin
  736. Part := EBP_SPECIALGROUPEXPAND;
  737. Base := Ord(tebSpecialGroupExpandSpecial);
  738. end;
  739. tebSpecialGroupHead:
  740. begin
  741. Part := EBP_SPECIALGROUPHEAD;
  742. Base := Ord(tebSpecialGroupHead);
  743. end;
  744. else
  745. Part := 0;
  746. Base := 0;
  747. end;
  748. State := Ord(Detail) - Base + 1;
  749. end;
  750. end;
  751. //----------------------------------------------------------------------------------------------------------------------
  752. function TThemeServices.GetElementDetails(Detail: TThemedHeader): TThemedElementDetails;
  753. var
  754. Base: Integer;
  755. begin
  756. Result.Element := teHeader;
  757. with Result do
  758. begin
  759. case Detail of
  760. thHeaderItemNormal..thHeaderItemPressed:
  761. begin
  762. Part := HP_HEADERITEM;
  763. Base := Ord(thHeaderItemNormal);
  764. end;
  765. thHeaderItemLeftNormal..thHeaderItemLeftPressed:
  766. begin
  767. Part := HP_HEADERITEMLEFT;
  768. Base := Ord(thHeaderItemLeftNormal);
  769. end;
  770. thHeaderItemRightNormal..thHeaderItemRightPressed:
  771. begin
  772. Part := HP_HEADERITEMRIGHT;
  773. Base := Ord(thHeaderItemRightNormal);
  774. end;
  775. thHeaderSortArrowSortedUp..thHeaderSortArrowSortedDown:
  776. begin
  777. Part := HP_HEADERSORTARROW;
  778. Base := Ord(thHeaderSortArrowSortedUp);
  779. end;
  780. else
  781. Part := 0;
  782. Base := 0;
  783. end;
  784. State := Ord(Detail) - Base + 1;
  785. end;
  786. end;
  787. //----------------------------------------------------------------------------------------------------------------------
  788. function TThemeServices.GetElementDetails(Detail: TThemedListview): TThemedElementDetails;
  789. var
  790. Base: Integer;
  791. begin
  792. Result.Element := teListView;
  793. with Result do
  794. begin
  795. case Detail of
  796. tlListItemNormal..tlListItemSelectedNotFocus:
  797. begin
  798. Part := LVP_LISTITEM;
  799. Base := Ord(tlListItemNormal);
  800. end;
  801. tlListGroup:
  802. begin
  803. Part := LVP_LISTGROUP;
  804. Base := Ord(tlListGroup);
  805. end;
  806. tlListDetail:
  807. begin
  808. Part := LVP_LISTDETAIL;
  809. Base := Ord(tlListDetail);
  810. end;
  811. tlListSortDetail:
  812. begin
  813. Part := LVP_LISTSORTEDDETAIL;
  814. Base := Ord(tlListSortDetail);
  815. end;
  816. tlEmptyText:
  817. begin
  818. Part := LVP_EMPTYTEXT;
  819. Base := Ord(tlEmptyText);
  820. end;
  821. else
  822. Part := 0;
  823. Base := 0;
  824. end;
  825. State := Ord(Detail) - Base + 1;
  826. end;
  827. end;
  828. //----------------------------------------------------------------------------------------------------------------------
  829. function TThemeServices.GetElementDetails(Detail: TThemedMenu): TThemedElementDetails;
  830. var
  831. Base: Integer;
  832. begin
  833. Result.Element := teMenu;
  834. with Result do
  835. begin
  836. case Detail of
  837. tmMenuItemNormal..tmMenuItemDemoted:
  838. begin
  839. Part := MP_MENUITEM;
  840. Base := Ord(tmMenuItemNormal);
  841. end;
  842. tmMenuDropDown:
  843. begin
  844. Part := MP_MENUDROPDOWN;
  845. Base := Ord(tmMenuDropDown);
  846. end;
  847. tmMenuBarItem:
  848. begin
  849. Part := MP_MENUBARITEM;
  850. Base := Ord(tmMenuBarItem);
  851. end;
  852. tmMenuBarDropDown:
  853. begin
  854. Part := MP_MENUBARDROPDOWN;
  855. Base := Ord(tmMenuBarDropDown);
  856. end;
  857. tmChevron:
  858. begin
  859. Part := MP_CHEVRON;
  860. Base := Ord(tmChevron);
  861. end;
  862. tmSeparator:
  863. begin
  864. Part := MP_SEPARATOR;
  865. Base := Ord(tmSeparator);
  866. end;
  867. else
  868. Part := 0;
  869. Base := 0;
  870. end;
  871. State := Ord(Detail) - Base + 1;
  872. end;
  873. end;
  874. //----------------------------------------------------------------------------------------------------------------------
  875. function TThemeServices.GetElementDetails(Detail: TThemedPage): TThemedElementDetails;
  876. var
  877. Base: Integer;
  878. begin
  879. Result.Element := tePage;
  880. with Result do
  881. begin
  882. case Detail of
  883. tpUpNormal..tpUpDisabled:
  884. begin
  885. Part := PGRP_UP;
  886. Base := Ord(tpUpNormal);
  887. end;
  888. tpDownNormal..tpDownDisabled:
  889. begin
  890. Part := PGRP_DOWN;
  891. Base := Ord(tpDownNormal);
  892. end;
  893. tpUpHorzNormal..tpUpHorzDisabled:
  894. begin
  895. Part := PGRP_UPHORZ;
  896. Base := Ord(tpUpHorzNormal);
  897. end;
  898. tpDownHorzNormal..tpDownHorzDisabled:
  899. begin
  900. Part := PGRP_DOWNHORZ;
  901. Base := Ord(tpDownHorzNormal);
  902. end;
  903. else
  904. Part := 0;
  905. Base := 0;
  906. end;
  907. State := Ord(Detail) - Base + 1;
  908. end;
  909. end;
  910. //----------------------------------------------------------------------------------------------------------------------
  911. function TThemeServices.GetElementDetails(Detail: TThemedProgress): TThemedElementDetails;
  912. var
  913. Base: Integer;
  914. begin
  915. Result.Element := teProgress;
  916. with Result do
  917. begin
  918. case Detail of
  919. tpBar:
  920. begin
  921. Part := PP_BAR;
  922. Base := Ord(tpBar);
  923. end;
  924. tpBarVert:
  925. begin
  926. Part := PP_BARVERT;
  927. Base := Ord(tpBarVert);
  928. end;
  929. tpChunk:
  930. begin
  931. Part := PP_CHUNK;
  932. Base := Ord(tpChunk);
  933. end;
  934. tpChunkVert:
  935. begin
  936. Part := PP_CHUNKVERT;
  937. Base := Ord(tpChunkVert);
  938. end;
  939. else
  940. Part := 0;
  941. Base := 0;
  942. end;
  943. State := Ord(Detail) - Base + 1;
  944. end;
  945. end;
  946. //----------------------------------------------------------------------------------------------------------------------
  947. function TThemeServices.GetElementDetails(Detail: TThemedRebar): TThemedElementDetails;
  948. var
  949. Base: Integer;
  950. begin
  951. Result.Element := teRebar;
  952. with Result do
  953. begin
  954. case Detail of
  955. trGripper:
  956. begin
  957. Part := RP_GRIPPER;
  958. Base := Ord(trGripper);
  959. end;
  960. trGripperVert:
  961. begin
  962. Part := RP_GRIPPERVERT;
  963. Base := Ord(trGripperVert);
  964. end;
  965. trBandNormal..trBandHotChecked:
  966. begin
  967. Part := RP_BAND;
  968. Base := Ord(trBandNormal);
  969. end;
  970. trChevronNormal..trChevronDisabled:
  971. begin
  972. Part := RP_CHEVRON;
  973. Base := Ord(trChevronNormal);
  974. end;
  975. trChevronVertNormal..trChevronVertDisabled:
  976. begin
  977. Part := RP_CHEVRONVERT;
  978. Base := Ord(trChevronVertNormal);
  979. end;
  980. else
  981. Part := 0;
  982. Base := 0;
  983. end;
  984. State := Ord(Detail) - Base + 1;
  985. end;
  986. end;
  987. //----------------------------------------------------------------------------------------------------------------------
  988. function TThemeServices.GetElementDetails(Detail: TThemedScrollBar): TThemedElementDetails;
  989. var
  990. Base: Integer;
  991. begin
  992. Result.Element := teScrollBar;
  993. with Result do
  994. begin
  995. case Detail of
  996. tsArrowBtnUpNormal..tsArrowBtnRightDisabled:
  997. begin
  998. Part := SBP_ARROWBTN;
  999. Base := Ord(tsArrowBtnUpNormal);
  1000. end;
  1001. tsThumbBtnHorzNormal..tsThumbBtnHorzDisabled:
  1002. begin
  1003. Part := SBP_THUMBBTNHORZ;
  1004. Base := Ord(tsThumbBtnHorzNormal);
  1005. end;
  1006. tsThumbBtnVertNormal..tsThumbBtnVertDisabled:
  1007. begin
  1008. Part := SBP_THUMBBTNVERT;
  1009. Base := Ord(tsThumbBtnVertNormal);
  1010. end;
  1011. tsLowerTrackHorzNormal..tsLowerTrackHorzDisabled:
  1012. begin
  1013. Part := SBP_LOWERTRACKHORZ;
  1014. Base := Ord(tsLowerTrackHorzNormal);
  1015. end;
  1016. tsUpperTrackHorzNormal..tsUpperTrackHorzDisabled:
  1017. begin
  1018. Part := SBP_UPPERTRACKHORZ;
  1019. Base := Ord(tsUpperTrackHorzNormal);
  1020. end;
  1021. tsLowerTrackVertNormal..tsLowerTrackVertDisabled:
  1022. begin
  1023. Part := SBP_LOWERTRACKVERT;
  1024. Base := Ord(tsLowerTrackVertNormal);
  1025. end;
  1026. tsUpperTrackVertNormal..tsUpperTrackVertDisabled:
  1027. begin
  1028. Part := SBP_UPPERTRACKVERT;
  1029. Base := Ord(tsUpperTrackVertNormal);
  1030. end;
  1031. tsGripperHorzNormal..tsGripperHorzDisabled:
  1032. begin
  1033. Part := SBP_GRIPPERHORZ;
  1034. Base := Ord(tsGripperHorzNormal);
  1035. end;
  1036. tsGripperVertNormal..tsGripperVertDisabled:
  1037. begin
  1038. Part := SBP_GRIPPERVERT;
  1039. Base := Ord(tsGripperVertNormal);
  1040. end;
  1041. tsSizeBoxRightAlign..tsSizeBoxLeftAlign:
  1042. begin
  1043. Part := SBP_SIZEBOX;
  1044. Base := Ord(tsSizeBoxRightAlign);
  1045. end;
  1046. else
  1047. Part := 0;
  1048. Base := 0;
  1049. end;
  1050. State := Ord(Detail) - Base + 1;
  1051. end;
  1052. end;
  1053. //----------------------------------------------------------------------------------------------------------------------
  1054. function TThemeServices.GetElementDetails(Detail: TThemedSpin): TThemedElementDetails;
  1055. var
  1056. Base: Integer;
  1057. begin
  1058. Result.Element := teSpin;
  1059. with Result do
  1060. begin
  1061. case Detail of
  1062. tsUpNormal..tsUpDisabled:
  1063. begin
  1064. Part := SPNP_UP;
  1065. Base := Ord(tsUpNormal);
  1066. end;
  1067. tsDownNormal..tsDownDisabled:
  1068. begin
  1069. Part := SPNP_DOWN;
  1070. Base := Ord(tsDownNormal);
  1071. end;
  1072. tsUpHorzNormal..tsUpHorzDisabled:
  1073. begin
  1074. Part := SPNP_UPHORZ;
  1075. Base := Ord(tsUpHorzNormal);
  1076. end;
  1077. tsDownHorzNormal..tsDownHorzDisabled:
  1078. begin
  1079. Part := SPNP_DOWNHORZ;
  1080. Base := Ord(tsDownHorzNormal);
  1081. end;
  1082. else
  1083. Part := 0;
  1084. Base := 0;
  1085. end;
  1086. State := Ord(Detail) - Base + 1;
  1087. end;
  1088. end;
  1089. //----------------------------------------------------------------------------------------------------------------------
  1090. function TThemeServices.GetElementDetails(Detail: TThemedStartPanel): TThemedElementDetails;
  1091. var
  1092. Base: Integer;
  1093. begin
  1094. Result.Element := teStartPanel;
  1095. with Result do
  1096. begin
  1097. case Detail of
  1098. tspUserPane:
  1099. begin
  1100. Part := SPP_USERPANE;
  1101. Base := Ord(tspUserPane);
  1102. end;
  1103. tspMorePrograms:
  1104. begin
  1105. Part := SPP_MOREPROGRAMS;
  1106. Base := Ord(tspMorePrograms);
  1107. end;
  1108. tspMoreProgramsArrowNormal..tspMoreProgramsArrowPressed:
  1109. begin
  1110. Part := SPP_MOREPROGRAMSARROW;
  1111. Base := Ord(tspMoreProgramsArrowNormal);
  1112. end;
  1113. tspProgList:
  1114. begin
  1115. Part := SPP_PROGLIST;
  1116. Base := Ord(tspProgList);
  1117. end;
  1118. tspProgListSeparator:
  1119. begin
  1120. Part := SPP_PROGLISTSEPARATOR;
  1121. Base := Ord(tspProgListSeparator);
  1122. end;
  1123. tspPlacesList:
  1124. begin
  1125. Part := SPP_PLACESLIST;
  1126. Base := Ord(tspPlacesList);
  1127. end;
  1128. tspPlacesListSeparator:
  1129. begin
  1130. Part := SPP_PLACESLISTSEPARATOR;
  1131. Base := Ord(tspPlacesListSeparator);
  1132. end;
  1133. tspLogOff:
  1134. begin
  1135. Part := SPP_LOGOFF;
  1136. Base := Ord(tspLogOff);
  1137. end;
  1138. tspLogOffButtonsNormal..tspLogOffButtonsPressed:
  1139. begin
  1140. Part := SPP_LOGOFFBUTTONS;
  1141. Base := Ord(tspLogOffButtonsNormal);
  1142. end;
  1143. tspUserPicture:
  1144. begin
  1145. Part := SPP_USERPICTURE;
  1146. Base := Ord(tspUserPicture);
  1147. end;
  1148. tspPreview:
  1149. begin
  1150. Part := SPP_PREVIEW;
  1151. Base := Ord(tspPreview);
  1152. end;
  1153. else
  1154. Part := 0;
  1155. Base := 0;
  1156. end;
  1157. State := Ord(Detail) - Base + 1;
  1158. end;
  1159. end;
  1160. //----------------------------------------------------------------------------------------------------------------------
  1161. function TThemeServices.GetElementDetails(Detail: TThemedStatus): TThemedElementDetails;
  1162. var
  1163. Base: Integer;
  1164. begin
  1165. Result.Element := teStatus;
  1166. with Result do
  1167. begin
  1168. case Detail of
  1169. tsPane:
  1170. begin
  1171. Part := SP_PANE;
  1172. Base := Ord(tsPane);
  1173. end;
  1174. tsGripperPane:
  1175. begin
  1176. Part := SP_GRIPPERPANE;
  1177. Base := Ord(tsGripperPane);
  1178. end;
  1179. tsGripper:
  1180. begin
  1181. Part := SP_GRIPPER;
  1182. Base := Ord(tsGripper);
  1183. end;
  1184. else
  1185. Part := 0;
  1186. Base := 0;
  1187. end;
  1188. State := Ord(Detail) - Base + 1;
  1189. end;
  1190. end;
  1191. //----------------------------------------------------------------------------------------------------------------------
  1192. function TThemeServices.GetElementDetails(Detail: TThemedTab): TThemedElementDetails;
  1193. var
  1194. Base: Integer;
  1195. begin
  1196. Result.Element := teTab;
  1197. with Result do
  1198. begin
  1199. case Detail of
  1200. ttTabItemNormal..ttTabItemFocused:
  1201. begin
  1202. Part := TABP_TABITEM;
  1203. Base := Ord(ttTabItemNormal);
  1204. end;
  1205. ttTabItemLeftEdgeNormal..ttTabItemLeftEdgeFocused:
  1206. begin
  1207. Part := TABP_TABITEMLEFTEDGE;
  1208. Base := Ord(ttTabItemLeftEdgeNormal);
  1209. end;
  1210. ttTabItemRightEdgeNormal..ttTabItemRightEdgeFocused:
  1211. begin
  1212. Part := TABP_TABITEMRIGHTEDGE;
  1213. Base := Ord(ttTabItemRightEdgeNormal);
  1214. end;
  1215. ttTabItemBothEdgeNormal..ttTabItemBothEdgeFocused:
  1216. begin
  1217. Part := TABP_TABITEMBOTHEDGE;
  1218. Base := Ord(ttTabItemBothEdgeNormal);
  1219. end;
  1220. ttTopTabItemNormal..ttTopTabItemFocused:
  1221. begin
  1222. Part := TABP_TOPTABITEM;
  1223. Base := Ord(ttTopTabItemNormal);
  1224. end;
  1225. ttTopTabItemLeftEdgeNormal..ttTopTabItemLeftEdgeFocused:
  1226. begin
  1227. Part := TABP_TOPTABITEMLEFTEDGE;
  1228. Base := Ord(ttTopTabItemLeftEdgeNormal);
  1229. end;
  1230. ttTopTabItemRightEdgeNormal..ttTopTabItemRightEdgeFocused:
  1231. begin
  1232. Part := TABP_TOPTABITEMRIGHTEDGE;
  1233. Base := Ord(ttTopTabItemRightEdgeNormal);
  1234. end;
  1235. ttTopTabItemBothEdgeNormal..ttTopTabItemBothEdgeFocused:
  1236. begin
  1237. Part := TABP_TOPTABITEMBOTHEDGE;
  1238. Base := Ord(ttTopTabItemBothEdgeNormal);
  1239. end;
  1240. ttPane:
  1241. begin
  1242. Part := TABP_PANE;
  1243. Base := Ord(ttPane);
  1244. end;
  1245. ttBody:
  1246. begin
  1247. Part := TABP_BODY;
  1248. Base := Ord(ttBody);
  1249. end;
  1250. else
  1251. Part := 0;
  1252. Base := 0;
  1253. end;
  1254. State := Ord(Detail) - Base + 1;
  1255. end;
  1256. end;
  1257. //----------------------------------------------------------------------------------------------------------------------
  1258. function TThemeServices.GetElementDetails(Detail: TThemedTaskBand): TThemedElementDetails;
  1259. var
  1260. Base: Integer;
  1261. begin
  1262. Result.Element := teTaskBand;
  1263. with Result do
  1264. begin
  1265. case Detail of
  1266. ttbGroupCount:
  1267. begin
  1268. Part := TDP_GROUPCOUNT;
  1269. Base := Ord(ttbGroupCount);
  1270. end;
  1271. ttbFlashButton:
  1272. begin
  1273. Part := TDP_FLASHBUTTON;
  1274. Base := Ord(ttbFlashButton);
  1275. end;
  1276. ttpFlashButtonGroupMenu:
  1277. begin
  1278. Part := TDP_FLASHBUTTONGROUPMENU;
  1279. Base := Ord(ttpFlashButtonGroupMenu);
  1280. end;
  1281. else
  1282. Part := 0;
  1283. Base := 0;
  1284. end;
  1285. State := Ord(Detail) - Base + 1;
  1286. end;
  1287. end;
  1288. //----------------------------------------------------------------------------------------------------------------------
  1289. function TThemeServices.GetElementDetails(Detail: TThemedTaskBar): TThemedElementDetails;
  1290. var
  1291. Base: Integer;
  1292. begin
  1293. Result.Element := teTaskBar;
  1294. with Result do
  1295. begin
  1296. case Detail of
  1297. ttbTimeNormal:
  1298. begin
  1299. Part := CLP_TIME;
  1300. Base := Ord(ttbTimeNormal);
  1301. end;
  1302. else
  1303. Part := 0;
  1304. Base := 0;
  1305. end;
  1306. State := Ord(Detail) - Base + 1;
  1307. end;
  1308. end;
  1309. //----------------------------------------------------------------------------------------------------------------------
  1310. function TThemeServices.GetElementDetails(Detail: TThemedToolBar): TThemedElementDetails;
  1311. var
  1312. Base: Integer;
  1313. begin
  1314. Result.Element := teToolBar;
  1315. with Result do
  1316. begin
  1317. case Detail of
  1318. ttbButtonNormal..ttbButtonCheckedHot:
  1319. begin
  1320. Part := TP_BUTTON;
  1321. Base := Ord(ttbButtonNormal);
  1322. end;
  1323. ttbDropDownButtonNormal..ttbDropDownButtonCheckedHot:
  1324. begin
  1325. Part := TP_DROPDOWNBUTTON;
  1326. Base := Ord(ttbDropDownButtonNormal);
  1327. end;
  1328. ttbSplitButtonNormal..ttbSplitButtonCheckedHot:
  1329. begin
  1330. Part := TP_SPLITBUTTON;
  1331. Base := Ord(ttbSplitButtonNormal);
  1332. end;
  1333. ttbSplitButtonDropDownNormal..ttbSplitButtonDropDownCheckedHot:
  1334. begin
  1335. Part := TP_SPLITBUTTONDROPDOWN;
  1336. Base := Ord(ttbSplitButtonDropDownNormal);
  1337. end;
  1338. ttbSeparatorNormal..ttbSeparatorCheckedHot:
  1339. begin
  1340. Part := TP_SEPARATOR;
  1341. Base := Ord(ttbSeparatorNormal);
  1342. end;
  1343. ttbSeparatorVertNormal..ttbSeparatorVertCheckedHot:
  1344. begin
  1345. Part := TP_SEPARATORVERT;
  1346. Base := Ord(ttbSeparatorVertNormal);
  1347. end;
  1348. else
  1349. Part := 0;
  1350. Base := 0;
  1351. end;
  1352. State := Ord(Detail) - Base + 1;
  1353. end;
  1354. end;
  1355. //----------------------------------------------------------------------------------------------------------------------
  1356. function TThemeServices.GetElementDetails(Detail: TThemedToolTip): TThemedElementDetails;
  1357. var
  1358. Base: Integer;
  1359. begin
  1360. Result.Element := teToolTip;
  1361. with Result do
  1362. begin
  1363. case Detail of
  1364. tttStandardNormal..tttStandardLink:
  1365. begin
  1366. Part := TTP_STANDARD;
  1367. Base := Ord(tttStandardNormal);
  1368. end;
  1369. tttStandardTitleNormal..tttStandardTitleLink:
  1370. begin
  1371. Part := TTP_STANDARDTITLE;
  1372. Base := Ord(tttStandardTitleNormal);
  1373. end;
  1374. tttBaloonNormal..tttBaloonLink:
  1375. begin
  1376. Part := TTP_BALLOON;
  1377. Base := Ord(tttBaloonNormal);
  1378. end;
  1379. tttBaloonTitleNormal..tttBaloonTitleLink:
  1380. begin
  1381. Part := TTP_BALLOONTITLE;
  1382. Base := Ord(tttBaloonTitleNormal);
  1383. end;
  1384. tttCloseNormal..tttClosePressed:
  1385. begin
  1386. Part := TTP_CLOSE;
  1387. Base := Ord(tttCloseNormal);
  1388. end;
  1389. else
  1390. Part := 0;
  1391. Base := 0;
  1392. end;
  1393. State := Ord(Detail) - Base + 1;
  1394. end;
  1395. end;
  1396. //----------------------------------------------------------------------------------------------------------------------
  1397. function TThemeServices.GetElementDetails(Detail: TThemedTrackBar): TThemedElementDetails;
  1398. var
  1399. Base: Integer;
  1400. begin
  1401. Result.Element := teTrackBar;
  1402. with Result do
  1403. begin
  1404. case Detail of
  1405. ttbTrack:
  1406. begin
  1407. Part := TKP_TRACK;
  1408. Base := Ord(ttbTrack);
  1409. end;
  1410. ttbTrackVert:
  1411. begin
  1412. Part := TKP_TRACKVERT;
  1413. Base := Ord(ttbTrackVert);
  1414. end;
  1415. ttbThumbNormal..ttbThumbDisabled:
  1416. begin
  1417. Part := TKP_THUMB;
  1418. Base := Ord(ttbThumbNormal);
  1419. end;
  1420. ttbThumbBottomNormal..ttbThumbBottomDisabled:
  1421. begin
  1422. Part := TKP_THUMBBOTTOM;
  1423. Base := Ord(ttbThumbBottomNormal);
  1424. end;
  1425. ttbThumbTopNormal..ttbThumbTopDisabled:
  1426. begin
  1427. Part := TKP_THUMBTOP;
  1428. Base := Ord(ttbThumbTopNormal);
  1429. end;
  1430. ttbThumbVertNormal..ttbThumbVertDisabled:
  1431. begin
  1432. Part := TKP_THUMBVERT;
  1433. Base := Ord(ttbThumbVertNormal);
  1434. end;
  1435. ttbThumbLeftNormal..ttbThumbLeftDisabled:
  1436. begin
  1437. Part := TKP_THUMBLEFT;
  1438. Base := Ord(ttbThumbLeftNormal);
  1439. end;
  1440. ttbThumbRightNormal..ttbThumbRightDisabled:
  1441. begin
  1442. Part := TKP_THUMBRIGHT;
  1443. Base := Ord(ttbThumbRightNormal);
  1444. end;
  1445. ttbThumbTics:
  1446. begin
  1447. Part := TKP_TICS;
  1448. Base := Ord(ttbThumbTics);
  1449. end;
  1450. ttbThumbTicsVert:
  1451. begin
  1452. Part := TKP_TICSVERT;
  1453. Base := Ord(ttbThumbTicsVert);
  1454. end;
  1455. else
  1456. Part := 0;
  1457. Base := 0;
  1458. end;
  1459. State := Ord(Detail) - Base + 1;
  1460. end;
  1461. end;
  1462. //----------------------------------------------------------------------------------------------------------------------
  1463. function TThemeServices.GetElementDetails(Detail: TThemedTrayNotify): TThemedElementDetails;
  1464. var
  1465. Base: Integer;
  1466. begin
  1467. Result.Element := teTrayNotify;
  1468. with Result do
  1469. begin
  1470. case Detail of
  1471. ttnBackground:
  1472. begin
  1473. Part := TNP_BACKGROUND;
  1474. Base := Ord(ttnBackground);
  1475. end;
  1476. ttnAnimBackground:
  1477. begin
  1478. Part := TNP_ANIMBACKGROUND;
  1479. Base := Ord(ttnAnimBackground);
  1480. end;
  1481. else
  1482. Part := 0;
  1483. Base := 0;
  1484. end;
  1485. State := Ord(Detail) - Base + 1;
  1486. end;
  1487. end;
  1488. //----------------------------------------------------------------------------------------------------------------------
  1489. function TThemeServices.GetElementDetails(Detail: TThemedTreeview): TThemedElementDetails;
  1490. var
  1491. Base: Integer;
  1492. begin
  1493. Result.Element := teTreeView;
  1494. with Result do
  1495. begin
  1496. case Detail of
  1497. ttItemNormal..ttItemSelectedNotFocus:
  1498. begin
  1499. Part := TVP_TREEITEM;
  1500. Base := Ord(ttItemNormal);
  1501. end;
  1502. ttGlyphClosed..ttGlyphOpened:
  1503. begin
  1504. Part := TVP_GLYPH;
  1505. Base := Ord(ttGlyphClosed);
  1506. end;
  1507. ttBranch:
  1508. begin
  1509. Part := TVP_BRANCH;
  1510. Base := Ord(ttBranch);
  1511. end;
  1512. else
  1513. Part := 0;
  1514. Base := 0;
  1515. end;
  1516. State := Ord(Detail) - Base + 1;
  1517. end;
  1518. end;
  1519. //----------------------------------------------------------------------------------------------------------------------
  1520. function TThemeServices.GetElementDetails(Detail: TThemedWindow): TThemedElementDetails;
  1521. var
  1522. Base: Integer;
  1523. begin
  1524. Result.Element := teWindow;
  1525. with Result do
  1526. begin
  1527. case Detail of
  1528. twCaptionActive..twCaptionDisabled:
  1529. begin
  1530. Part := WP_CAPTION;
  1531. Base := Ord(twCaptionActive);
  1532. end;
  1533. twSmallCaptionActive..twSmallCaptionDisabled:
  1534. begin
  1535. Part := WP_SMALLCAPTION;
  1536. Base := Ord(twSmallCaptionActive);
  1537. end;
  1538. twMinCaptionActive..twMinCaptionDisabled:
  1539. begin
  1540. Part := WP_MINCAPTION;
  1541. Base := Ord(twMinCaptionActive);
  1542. end;
  1543. twSmallMinCaptionActive..twSmallMinCaptionDisabled:
  1544. begin
  1545. Part := WP_SMALLMINCAPTION;
  1546. Base := Ord(twSmallMinCaptionActive);
  1547. end;
  1548. twMaxCaptionActive..twMaxCaptionDisabled:
  1549. begin
  1550. Part := WP_MAXCAPTION;
  1551. Base := Ord(twMaxCaptionActive);
  1552. end;
  1553. twSmallMaxCaptionActive..twSmallMaxCaptionDisabled:
  1554. begin
  1555. Part := WP_SMALLMAXCAPTION;
  1556. Base := Ord(twSmallMaxCaptionActive);
  1557. end;
  1558. twFrameLeftActive..twFrameLeftInactive:
  1559. begin
  1560. Part := WP_FRAMELEFT;
  1561. Base := Ord(twFrameLeftActive);
  1562. end;
  1563. twFrameRightActive..twFrameRightInactive:
  1564. begin
  1565. Part := WP_FRAMERIGHT;
  1566. Base := Ord(twFrameRightActive);
  1567. end;
  1568. twFrameBottomActive..twFrameBottomInactive:
  1569. begin
  1570. Part := WP_FRAMEBOTTOM;
  1571. Base := Ord(twFrameBottomActive);
  1572. end;
  1573. twSmallFrameLeftActive..twSmallFrameLeftInactive:
  1574. begin
  1575. Part := WP_SMALLFRAMELEFT;
  1576. Base := Ord(twSmallFrameLeftActive);
  1577. end;
  1578. twSmallFrameRightActive..twSmallFrameRightInactive:
  1579. begin
  1580. Part := WP_SMALLFRAMERIGHT;
  1581. Base := Ord(twSmallFrameRightActive);
  1582. end;
  1583. twSmallFrameBottomActive..twSmallFrameBottomInactive:
  1584. begin
  1585. Part := WP_SMALLFRAMEBOTTOM;
  1586. Base := Ord(twSmallFrameBottomActive);
  1587. end;
  1588. twSysButtonNormal..twSysButtonInactive:
  1589. begin
  1590. Part := WP_SYSBUTTON;
  1591. Base := Ord(twSysButtonNormal);
  1592. end;
  1593. twMDISysButtonNormal..twMDISysButtonInactive:
  1594. begin
  1595. Part := WP_MDISYSBUTTON;
  1596. Base := Ord(twMDISysButtonNormal);
  1597. end;
  1598. twMinButtonNormal..twMinButtonInactive:
  1599. begin
  1600. Part := WP_MINBUTTON;
  1601. Base := Ord(twMinButtonNormal);
  1602. end;
  1603. twMDIMinButtonNormal..twMDIMinButtonInactive:
  1604. begin
  1605. Part := WP_MDIMINBUTTON;
  1606. Base := Ord(twMDIMinButtonNormal);
  1607. end;
  1608. twMaxButtonNormal..twMaxButtonInactive:
  1609. begin
  1610. Part := WP_MAXBUTTON;
  1611. Base := Ord(twMaxButtonNormal);
  1612. end;
  1613. twCloseButtonNormal..twCloseButtonInactive:
  1614. begin
  1615. Part := WP_CLOSEBUTTON;
  1616. Base := Ord(twCloseButtonNormal);
  1617. end;
  1618. twSmallCloseButtonNormal..twSmallCloseButtonInactive:
  1619. begin
  1620. Part := WP_SMALLCLOSEBUTTON;
  1621. Base := Ord(twSmallCloseButtonNormal);
  1622. end;
  1623. twMDICloseButtonNormal..twMDICloseButtonInactive:
  1624. begin
  1625. Part := WP_MDICLOSEBUTTON;
  1626. Base := Ord(twMDICloseButtonNormal);
  1627. end;
  1628. twRestoreButtonNormal..twRestoreButtonInactive:
  1629. begin
  1630. Part := WP_RESTOREBUTTON;
  1631. Base := Ord(twRestoreButtonNormal);
  1632. end;
  1633. twMDIRestoreButtonNormal..twMDIRestoreButtonInactive:
  1634. begin
  1635. Part := WP_MDIRESTOREBUTTON;
  1636. Base := Ord(twMDIRestoreButtonNormal);
  1637. end;
  1638. twHelpButtonNormal..twHelpButtonInactive:
  1639. begin
  1640. Part := WP_HELPBUTTON;
  1641. Base := Ord(twHelpButtonNormal);
  1642. end;
  1643. twMDIHelpButtonNormal..twMDIHelpButtonInactive:
  1644. begin
  1645. Part := WP_MDIHELPBUTTON;
  1646. Base := Ord(twMDIHelpButtonNormal);
  1647. end;
  1648. twHorzScrollNormal..twHorzScrollDisabled:
  1649. begin
  1650. Part := WP_HORZSCROLL;
  1651. Base := Ord(twHorzScrollNormal);
  1652. end;
  1653. twHorzThumbNormal..twHorzThumbDisabled:
  1654. begin
  1655. Part := WP_HORZTHUMB;
  1656. Base := Ord(twHorzThumbNormal);
  1657. end;
  1658. twVertScrollNormal..twVertScrollDisabled:
  1659. begin
  1660. Part := WP_VERTSCROLL;
  1661. Base := Ord(twVertScrollNormal);
  1662. end;
  1663. twVertThumbNormal..twVertThumbDisabled:
  1664. begin
  1665. Part := WP_VERTTHUMB;
  1666. Base := Ord(twVertThumbNormal);
  1667. end;
  1668. twDialog:
  1669. begin
  1670. Part := WP_DIALOG;
  1671. Base := Ord(twDialog);
  1672. end;
  1673. twCaptionSizingTemplate:
  1674. begin
  1675. Part := WP_CAPTIONSIZINGTEMPLATE;
  1676. Base := Ord(twCaptionSizingTemplate);
  1677. end;
  1678. twSmallCaptionSizingTemplate:
  1679. begin
  1680. Part := WP_SMALLCAPTIONSIZINGTEMPLATE;
  1681. Base := Ord(twSmallCaptionSizingTemplate);
  1682. end;
  1683. twFrameLeftSizingTemplate:
  1684. begin
  1685. Part := WP_FRAMELEFTSIZINGTEMPLATE;
  1686. Base := Ord(twFrameLeftSizingTemplate);
  1687. end;
  1688. twSmallFrameLeftSizingTemplate:
  1689. begin
  1690. Part := WP_SMALLFRAMELEFTSIZINGTEMPLATE;
  1691. Base := Ord(twSmallFrameLeftSizingTemplate);
  1692. end;
  1693. twFrameRightSizingTemplate:
  1694. begin
  1695. Part := WP_FRAMERIGHTSIZINGTEMPLATE;
  1696. Base := Ord(twFrameRightSizingTemplate);
  1697. end;
  1698. twSmallFrameRightSizingTemplate:
  1699. begin
  1700. Part := WP_SMALLFRAMERIGHTSIZINGTEMPLATE;
  1701. Base := Ord(twSmallFrameRightSizingTemplate);
  1702. end;
  1703. twFrameBottomSizingTemplate:
  1704. begin
  1705. Part := WP_FRAMEBOTTOMSIZINGTEMPLATE;
  1706. Base := Ord(twFrameBottomSizingTemplate);
  1707. end;
  1708. twSmallFrameBottomSizingTemplate:
  1709. begin
  1710. Part := WP_SMALLFRAMEBOTTOMSIZINGTEMPLATE;
  1711. Base := Ord(twSmallFrameBottomSizingTemplate);
  1712. end;
  1713. else
  1714. Part := 0;
  1715. Base := 0;
  1716. end;
  1717. State := Ord(Detail) - Base + 1;
  1718. end;
  1719. end;
  1720. //----------------------------------------------------------------------------------------------------------------------
  1721. function TThemeServices.ColorToRGB(Color: TColor; Details: PThemedElementDetails = nil): COLORREF;
  1722. begin
  1723. if (Color and $80000000 = 0) or (Details = nil) then
  1724. Result := Color
  1725. else
  1726. Result := GetThemeSysColor(Theme[Details.Element], Color and not $80000000);
  1727. end;
  1728. //----------------------------------------------------------------------------------------------------------------------
  1729. function TThemeServices.ContentRect(DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect;
  1730. begin
  1731. with Details do
  1732. GetThemeBackgroundContentRect(Theme[Element], DC, Part, State, BoundingRect, @Result);
  1733. end;
  1734. //----------------------------------------------------------------------------------------------------------------------
  1735. procedure TThemeServices.DrawEdge(DC: HDC; Details: TThemedElementDetails; const R: TRect; Edge, Flags: Cardinal;
  1736. ContentRect: PRect = nil);
  1737. begin
  1738. with Details do
  1739. DrawThemeEdge(Theme[Element], DC, Part, State, R, Edge, Flags, ContentRect);
  1740. end;
  1741. //----------------------------------------------------------------------------------------------------------------------
  1742. procedure TThemeServices.DrawElement(DC: HDC; Details: TThemedElementDetails; const R: TRect; ClipRect: PRect = nil);
  1743. begin
  1744. with Details do
  1745. DrawThemeBackground(Theme[Element], DC, Part, State, R, ClipRect);
  1746. end;
  1747. //----------------------------------------------------------------------------------------------------------------------
  1748. procedure TThemeServices.DrawIcon(DC: HDC; Details: TThemedElementDetails; const R: TRect; himl: HIMAGELIST;
  1749. Index: Integer);
  1750. begin
  1751. with Details do
  1752. DrawThemeIcon(Theme[Element], DC, Part, State, R, himl, Index);
  1753. end;
  1754. //----------------------------------------------------------------------------------------------------------------------
  1755. procedure TThemeServices.DrawParentBackground(Window: HWND; Target: HDC; Details: PThemedElementDetails;
  1756. OnlyIfTransparent: Boolean; Bounds: PRect = nil);
  1757. var
  1758. DoDraw: Boolean;
  1759. begin
  1760. if OnlyIfTransparent and Assigned(Details) then
  1761. begin
  1762. with Details^ do
  1763. DoDraw := IsThemeBackgroundPartiallyTransparent(Theme[Element], Part, State);
  1764. end
  1765. else
  1766. DoDraw := True;
  1767. if DoDraw then
  1768. DrawThemeParentBackground(Window, Target, Bounds);
  1769. end;
  1770. //----------------------------------------------------------------------------------------------------------------------
  1771. procedure TThemeServices.DrawText(DC: HDC; Details: TThemedElementDetails; const S: WideString; R: TRect; Flags,
  1772. Flags2: Cardinal);
  1773. begin
  1774. with Details do
  1775. DrawThemeText(Theme[Element], DC, Part, State, PWideChar(S), Length(S), Flags, Flags2, R);
  1776. end;
  1777. //----------------------------------------------------------------------------------------------------------------------
  1778. function TThemeServices.HasTransparentParts(Details: TThemedElementDetails): Boolean;
  1779. begin
  1780. with Details do
  1781. Result := IsThemeBackgroundPartiallyTransparent(Theme[Element], Part, State);
  1782. end;
  1783. //----------------------------------------------------------------------------------------------------------------------
  1784. procedure TThemeServices.PaintBorder(Control: TWinControl; EraseLRCorner: Boolean);
  1785. var
  1786. EmptyRect,
  1787. DrawRect: TRect;
  1788. DC: HDC;
  1789. H, W: Integer;
  1790. AStyle,
  1791. ExStyle: Integer;
  1792. Details: TThemedElementDetails;
  1793. begin
  1794. with Control do
  1795. begin
  1796. ExStyle := GetWindowLong(Handle, GWL_EXSTYLE);
  1797. if (ExStyle and WS_EX_CLIENTEDGE) <> 0 then
  1798. begin
  1799. GetWindowRect(Handle, DrawRect);
  1800. OffsetRect(DrawRect, -DrawRect.Left, -DrawRect.Top);
  1801. DC := GetWindowDC(Handle);
  1802. try
  1803. EmptyRect := DrawRect;
  1804. if EraseLRCorner then
  1805. begin
  1806. AStyle := GetWindowLong(Handle, GWL_STYLE);
  1807. if ((AStyle and WS_HSCROLL) <> 0) and ((AStyle and WS_VSCROLL) <> 0) then
  1808. begin
  1809. W := GetSystemMetrics(SM_CXVSCROLL);
  1810. H := GetSystemMetrics(SM_CYHSCROLL);
  1811. InflateRect(EmptyRect, -2, -2);
  1812. with EmptyRect do
  1813. EmptyRect := Rect(Right - W, Bottom - H, Right, Bottom);
  1814. FillRect(DC, EmptyRect, GetSysColorBrush(COLOR_BTNFACE));
  1815. end;
  1816. end;
  1817. with DrawRect do
  1818. ExcludeClipRect(DC, Left + 2, Top + 2, Right - 2, Bottom - 2);
  1819. Details := GetElementDetails(teEditTextNormal);
  1820. DrawElement(DC, Details, DrawRect);
  1821. finally
  1822. ReleaseDC(Handle, DC);
  1823. end;
  1824. end;
  1825. end;
  1826. end;
  1827. //----------------------------------------------------------------------------------------------------------------------
  1828. const
  1829. ComCtlVersionIE6 = $00060000;
  1830. procedure TThemeServices.UpdateThemes;
  1831. var
  1832. Flags: DWORD;
  1833. begin
  1834. if FUseThemes then
  1835. UnloadThemeData;
  1836. FUseThemes := UseThemes and (GetComCtlVersion >= ComCtlVersionIE6);
  1837. if FUseThemes then
  1838. begin
  1839. Flags := GetThemeAppProperties;
  1840. if (Flags and STAP_ALLOW_CONTROLS) = 0 then
  1841. FControlsEnabled := False
  1842. else
  1843. FControlsEnabled := True;
  1844. end
  1845. else
  1846. FControlsEnabled := False;
  1847. end;
  1848. //----------------------------------------------------------------------------------------------------------------------
  1849. // MP BEGIN
  1850. function TThemeServices.GetColor(Element: TThemedElement; PartId: Integer;
  1851. StateId: Integer; PropId: Integer): TColor;
  1852. var
  1853. RGB: TColorRef;
  1854. begin
  1855. RGB := 0;
  1856. GetThemeColor(Theme[Element], PartId, StateId, PropId, RGB);
  1857. Result := RGB;
  1858. end;
  1859. // MP END
  1860. //----------------------------------------------------------------------------------------------------------------------
  1861. initialization
  1862. finalization
  1863. InternalThemeServices.Free;
  1864. end.