| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077 |
- unit ThemeSrv;
- //----------------------------------------------------------------------------------------------------------------------
- // Windows XP Theme Manager is freeware. You may freely use it in any software, including commercial software, provided
- // you accept the following conditions:
- //
- // 1) The software may not be included into component collections and similar compilations which are sold. If you want
- // to distribute this software for money then contact me first and ask for my permission.
- // 2) My copyright notices in the source code may not be removed or modified.
- // 3) If you modify and/or distribute the code to any third party then you must not veil the original author. It must
- // always be clearly identifiable that I, Mike Lischke, am the original author.
- // Although it is not required it would be a nice move to recognize my work by adding a citation to the application's
- // about box or a similar place.
- //
- // The original code is ThemeSrv.pas, released 03. February 2002.
- //
- // The initial developer of the original code is:
- // Mike Lischke ([email protected], www.soft-gems.net).
- //
- // Portions created by Mike Lischke are
- // (C) 2001-2005 Mike Lischke. All Rights Reserved.
- //----------------------------------------------------------------------------------------------------------------------
- //
- // This unit contains the implementation of TThemeServices which is a designed to manage all necessary aspects of
- // the Windows XP (and up) theme APIs. The component is responsible for loading and unloading of the theme DLL
- // and offers properties and methods to test for various aspects of the theme APIs and to ease painting of themed
- // window content.
- //
- // The TThemeServices class is designed to work for controls which need XP paint stuff. It does not manipulate
- // any VCL class (for this task TThemeManager is responsible) and can be used standalone (also as general support
- // tool in an application). Using the global ThemeServices function you can implicitely create and use a single
- // instance of the class. Theme Manager uses the same approach.
- //----------------------------------------------------------------------------------------------------------------------
- // For version information and history see ThemeMgr.pas source file.
- //----------------------------------------------------------------------------------------------------------------------
- interface
- uses
- Windows, Classes, Messages, Graphics, Controls,
- UxTheme, TmSchema;
- {$I Compilers.inc}
- type
- // These are all elements which can be themed.
- TThemedElement = (
- teButton,
- teClock,
- teComboBox,
- teEdit,
- teExplorerBar,
- teHeader,
- teListView,
- teMenu,
- tePage,
- teProgress,
- teRebar,
- teScrollBar,
- teSpin,
- teStartPanel,
- teStatus,
- teTab,
- teTaskBand,
- teTaskBar,
- teToolBar,
- teToolTip,
- teTrackBar,
- teTrayNotify,
- teTreeview,
- teWindow
- );
- // 'Button' theme data
- TThemedButton = (
- tbButtonDontCare,
- tbButtonRoot, // The root part of each element is sometimes used for special painting and does not
- // belong to a certain state.
- tbPushButtonNormal, tbPushButtonHot, tbPushButtonPressed, tbPushButtonDisabled, tbPushButtonDefaulted,
- tbRadioButtonUncheckedNormal, tbRadioButtonUncheckedHot, tbRadioButtonUncheckedPressed, tbRadioButtonUncheckedDisabled,
- tbRadioButtonCheckedNormal, tbRadioButtonCheckedHot, tbRadioButtonCheckedPressed, tbRadioButtonCheckedDisabled,
- tbCheckBoxUncheckedNormal, tbCheckBoxUncheckedHot, tbCheckBoxUncheckedPressed, tbCheckBoxUncheckedDisabled,
- tbCheckBoxCheckedNormal, tbCheckBoxCheckedHot, tbCheckBoxCheckedPressed, tbCheckBoxCheckedDisabled,
- tbCheckBoxMixedNormal, tbCheckBoxMixedHot, tbCheckBoxMixedPressed, tbCheckBoxMixedDisabled,
- tbGroupBoxNormal, tbGroupBoxDisabled,
- tbUserButton
- );
- // 'Clock' theme data
- TThemedClock = (
- tcClockDontCare,
- tcClockRoot,
- tcTimeNormal
- );
- // 'ComboBox' theme data
- TThemedComboBox = (
- tcComboBoxDontCare,
- tcComboBoxRoot,
- tcDropDownButtonNormal, tcDropDownButtonHot, tcDropDownButtonPressed, tcDropDownButtonDisabled
- );
- // 'Edit' theme data
- TThemedEdit = (
- teEditDontCare,
- teEditRoot,
- teEditTextNormal, teEditTextHot, teEditTextSelected, teEditTextDisabled, teEditTextFocused, teEditTextReadOnly, teEditTextAssist,
- teEditCaret
- );
- // 'ExplorerBar' theme data
- TThemedExplorerBar = (
- tebExplorerBarDontCare,
- tebExplorerBarRoot,
- tebHeaderBackgroundNormal, tebHeaderBackgroundHot, tebHeaderBackgroundPressed,
- tebHeaderCloseNormal, tebHeaderCloseHot, tebHeaderClosePressed,
- tebHeaderPinNormal, tebHeaderPinHot, tebHeaderPinPressed,
- tebHeaderPinSelectedNormal, tebHeaderPinSelectedHot, tebHeaderPinSelectedPressed,
- tebIEBarMenuNormal, tebIEBarMenuHot, tebIEBarMenuPressed,
- tebNormalGroupBackground,
- tebNormalGroupCollapseNormal, tebNormalGroupCollapseHot, tebNormalGroupCollapsePressed,
- tebNormalGroupExpandNormal, tebNormalGroupExpandHot, tebNormalGroupExpandPressed,
- tebNormalGroupHead,
- tebSpecialGroupBackground,
- tebSpecialGroupCollapseSpecial, tebSpecialGroupCollapseHot, tebSpecialGroupCollapsePressed,
- tebSpecialGroupExpandSpecial, tebSpecialGroupExpandHot, tebSpecialGroupExpandPressed,
- tebSpecialGroupHead
- );
- // 'Header' theme data
- TThemedHeader = (
- thHeaderDontCare,
- thHeaderRoot,
- thHeaderItemNormal, thHeaderItemHot, thHeaderItemPressed,
- thHeaderItemLeftNormal, thHeaderItemLeftHot, thHeaderItemLeftPressed,
- thHeaderItemRightNormal, thHeaderItemRightHot, thHeaderItemRightPressed,
- thHeaderSortArrowSortedUp, thHeaderSortArrowSortedDown
- );
- // 'ListView' theme data
- TThemedListview = (
- tlListviewDontCare,
- tlListviewRoot,
- tlListItemNormal, tlListItemHot, tlListItemSelected, tlListItemDisabled, tlListItemSelectedNotFocus,
- tlListGroup,
- tlListDetail,
- tlListSortDetail,
- tlEmptyText
- );
- // 'Menu' theme data
- TThemedMenu = (
- tmMenuDontCare,
- tmMenuRoot,
- tmMenuItemNormal, tmMenuItemSelected, tmMenuItemDemoted,
- tmMenuDropDown,
- tmMenuBarItem,
- tmMenuBarDropDown,
- tmChevron,
- tmSeparator
- );
- // 'Page' theme data
- TThemedPage = (
- tpPageDontCare,
- tpPageRoot,
- tpUpNormal, tpUpHot, tpUpPressed, tpUpDisabled,
- tpDownNormal, tpDownHot, tpDownPressed, tpDownDisabled,
- tpUpHorzNormal, tpUpHorzHot, tpUpHorzPressed, tpUpHorzDisabled,
- tpDownHorzNormal, tpDownHorzHot, tpDownHorzPressed, tpDownHorzDisabled
- );
- // 'Progress' theme data
- TThemedProgress = (
- tpProgressDontCare,
- tpProgressRoot,
- tpBar,
- tpBarVert,
- tpChunk,
- tpChunkVert
- );
- // 'Rebar' theme data
- TThemedRebar = (
- trRebarDontCare,
- trRebarRoot,
- trGripper,
- trGripperVert,
- trBandNormal, trBandHot, trBandPressed, trBandDisabled, trBandChecked, trBandHotChecked,
- trChevronNormal, trChevronHot, trChevronPressed, trChevronDisabled,
- trChevronVertNormal, trChevronVertHot, trChevronVertPressed, trChevronVertDisabled
- );
- // 'ScrollBar' theme data
- TThemedScrollBar = (
- tsScrollBarDontCare,
- tsScrollBarRoot,
- tsArrowBtnUpNormal, tsArrowBtnUpHot, tsArrowBtnUpPressed, tsArrowBtnUpDisabled,
- tsArrowBtnDownNormal, tsArrowBtnDownHot, tsArrowBtnDownPressed, tsArrowBtnDownDisabled,
- tsArrowBtnLeftNormal, tsArrowBtnLeftHot, tsArrowBtnLeftPressed, tsArrowBtnLeftDisabled,
- tsArrowBtnRightNormal, tsArrowBtnRightHot, tsArrowBtnRightPressed, tsArrowBtnRightDisabled,
- tsThumbBtnHorzNormal, tsThumbBtnHorzHot, tsThumbBtnHorzPressed, tsThumbBtnHorzDisabled,
- tsThumbBtnVertNormal, tsThumbBtnVertHot, tsThumbBtnVertPressed, tsThumbBtnVertDisabled,
- tsLowerTrackHorzNormal, tsLowerTrackHorzHot, tsLowerTrackHorzPressed, tsLowerTrackHorzDisabled,
- tsUpperTrackHorzNormal, tsUpperTrackHorzHot, tsUpperTrackHorzPressed, tsUpperTrackHorzDisabled,
- tsLowerTrackVertNormal, tsLowerTrackVertHot, tsLowerTrackVertPressed, tsLowerTrackVertDisabled,
- tsUpperTrackVertNormal, tsUpperTrackVertHot, tsUpperTrackVertPressed, tsUpperTrackVertDisabled,
- tsGripperHorzNormal, tsGripperHorzHot, tsGripperHorzPressed, tsGripperHorzDisabled,
- tsGripperVertNormal, tsGripperVertHot, tsGripperVertPressed, tsGripperVertDisabled,
- tsSizeBoxRightAlign, tsSizeBoxLeftAlign
- );
- // 'Spin' theme data
- TThemedSpin = (
- tsSpinDontCare,
- tsSpinRoot,
- tsUpNormal, tsUpHot, tsUpPressed, tsUpDisabled,
- tsDownNormal, tsDownHot, tsDownPressed, tsDownDisabled,
- tsUpHorzNormal, tsUpHorzHot, tsUpHorzPressed, tsUpHorzDisabled,
- tsDownHorzNormal, tsDownHorzHot, tsDownHorzPressed, tsDownHorzDisabled
- );
- // 'StartPanel' theme data
- TThemedStartPanel = (
- tspStartPanelDontCare,
- tspStartPanelRoot,
- tspUserPane,
- tspMorePrograms,
- tspMoreProgramsArrowNormal, tspMoreProgramsArrowHot, tspMoreProgramsArrowPressed,
- tspProgList,
- tspProgListSeparator,
- tspPlacesList,
- tspPlacesListSeparator,
- tspLogOff,
- tspLogOffButtonsNormal, tspLogOffButtonsHot, tspLogOffButtonsPressed,
- tspUserPicture,
- tspPreview
- );
- // 'Status' theme data
- TThemedStatus = (
- tsStatusDontCare,
- tsStatusRoot,
- tsPane,
- tsGripperPane,
- tsGripper
- );
- // 'Tab' theme data
- TThemedTab = (
- ttTabDontCare,
- ttTabRoot,
- ttTabItemNormal, ttTabItemHot, ttTabItemSelected, ttTabItemDisabled, ttTabItemFocused,
- ttTabItemLeftEdgeNormal, ttTabItemLeftEdgeHot, ttTabItemLeftEdgeSelected, ttTabItemLeftEdgeDisabled, ttTabItemLeftEdgeFocused,
- ttTabItemRightEdgeNormal, ttTabItemRightEdgeHot, ttTabItemRightEdgeSelected, ttTabItemRightEdgeDisabled, ttTabItemRightEdgeFocused,
- ttTabItemBothEdgeNormal, ttTabItemBothEdgeHot, ttTabItemBothEdgeSelected, ttTabItemBothEdgeDisabled, ttTabItemBothEdgeFocused,
- ttTopTabItemNormal, ttTopTabItemHot, ttTopTabItemSelected, ttTopTabItemDisabled, ttTopTabItemFocused,
- ttTopTabItemLeftEdgeNormal, ttTopTabItemLeftEdgeHot, ttTopTabItemLeftEdgeSelected, ttTopTabItemLeftEdgeDisabled, ttTopTabItemLeftEdgeFocused,
- ttTopTabItemRightEdgeNormal, ttTopTabItemRightEdgeHot, ttTopTabItemRightEdgeSelected, ttTopTabItemRightEdgeDisabled, ttTopTabItemRightEdgeFocused,
- ttTopTabItemBothEdgeNormal, ttTopTabItemBothEdgeHot, ttTopTabItemBothEdgeSelected, ttTopTabItemBothEdgeDisabled, ttTopTabItemBothEdgeFocused,
- ttPane,
- ttBody
- );
- // 'TaskBand' theme data
- TThemedTaskBand = (
- ttbTaskBandDontCare,
- ttbTaskBandRoot,
- ttbGroupCount,
- ttbFlashButton,
- ttpFlashButtonGroupMenu
- );
- // 'TaskBar' theme data
- TThemedTaskBar = (
- ttTaskBarDontCare,
- ttTaskBarRoot,
- ttbTimeNormal
- );
- // 'ToolBar' theme data
- TThemedToolBar = (
- ttbToolBarDontCare,
- ttbToolBarRoot,
- ttbButtonNormal, ttbButtonHot, ttbButtonPressed, ttbButtonDisabled, ttbButtonChecked, ttbButtonCheckedHot,
- ttbDropDownButtonNormal, ttbDropDownButtonHot, ttbDropDownButtonPressed, ttbDropDownButtonDisabled, ttbDropDownButtonChecked, ttbDropDownButtonCheckedHot,
- ttbSplitButtonNormal, ttbSplitButtonHot, ttbSplitButtonPressed, ttbSplitButtonDisabled, ttbSplitButtonChecked, ttbSplitButtonCheckedHot,
- ttbSplitButtonDropDownNormal, ttbSplitButtonDropDownHot, ttbSplitButtonDropDownPressed, ttbSplitButtonDropDownDisabled, ttbSplitButtonDropDownChecked, ttbSplitButtonDropDownCheckedHot,
- ttbSeparatorNormal, ttbSeparatorHot, ttbSeparatorPressed, ttbSeparatorDisabled, ttbSeparatorChecked, ttbSeparatorCheckedHot,
- ttbSeparatorVertNormal, ttbSeparatorVertHot, ttbSeparatorVertPressed, ttbSeparatorVertDisabled, ttbSeparatorVertChecked, ttbSeparatorVertCheckedHot
- );
- // 'ToolTip' theme data
- TThemedToolTip = (
- tttToolTipDontCare,
- tttToolTipRoot,
- tttStandardNormal, tttStandardLink,
- tttStandardTitleNormal, tttStandardTitleLink,
- tttBaloonNormal, tttBaloonLink,
- tttBaloonTitleNormal, tttBaloonTitleLink,
- tttCloseNormal, tttCloseHot, tttClosePressed
- );
- // 'TrackBar' theme data
- TThemedTrackBar = (
- ttbTrackBarDontCare,
- ttbTrackBarRoot,
- ttbTrack,
- ttbTrackVert,
- ttbThumbNormal, ttbThumbHot, ttbThumbPressed, ttbThumbFocused, ttbThumbDisabled,
- ttbThumbBottomNormal, ttbThumbBottomHot, ttbThumbBottomPressed, ttbThumbBottomFocused, ttbThumbBottomDisabled,
- ttbThumbTopNormal, ttbThumbTopHot, ttbThumbTopPressed, ttbThumbTopFocused, ttbThumbTopDisabled,
- ttbThumbVertNormal, ttbThumbVertHot, ttbThumbVertPressed, ttbThumbVertFocused, ttbThumbVertDisabled,
- ttbThumbLeftNormal, ttbThumbLeftHot, ttbThumbLeftPressed, ttbThumbLeftFocused, ttbThumbLeftDisabled,
- ttbThumbRightNormal, ttbThumbRightHot, ttbThumbRightPressed, ttbThumbRightFocused, ttbThumbRightDisabled,
- ttbThumbTics,
- ttbThumbTicsVert
- );
- // 'TrayNotify' theme data
- TThemedTrayNotify = (
- ttnTrayNotifyDontCare,
- ttnTrayNotifyRoot,
- ttnBackground,
- ttnAnimBackground
- );
- // 'Treeview' theme data
- TThemedTreeview = (
- ttTreeviewDontCare,
- ttTreeviewRoot,
- ttItemNormal, ttItemHot, ttItemSelected, ttItemDisabled, ttItemSelectedNotFocus,
- ttGlyphClosed, ttGlyphOpened,
- ttBranch
- );
- // 'Window' theme data
- TThemedWindow = (
- twWindowDontCare,
- twWindowRoot,
- twCaptionActive, twCaptionInactive, twCaptionDisabled,
- twSmallCaptionActive, twSmallCaptionInactive, twSmallCaptionDisabled,
- twMinCaptionActive, twMinCaptionInactive, twMinCaptionDisabled,
- twSmallMinCaptionActive, twSmallMinCaptionInactive, twSmallMinCaptionDisabled,
- twMaxCaptionActive, twMaxCaptionInactive, twMaxCaptionDisabled,
- twSmallMaxCaptionActive, twSmallMaxCaptionInactive, twSmallMaxCaptionDisabled,
- twFrameLeftActive, twFrameLeftInactive,
- twFrameRightActive, twFrameRightInactive,
- twFrameBottomActive, twFrameBottomInactive,
- twSmallFrameLeftActive, twSmallFrameLeftInactive,
- twSmallFrameRightActive, twSmallFrameRightInactive,
- twSmallFrameBottomActive, twSmallFrameBottomInactive,
- twSysButtonNormal, twSysButtonHot, twSysButtonPushed, twSysButtonDisabled, twSysButtonInactive,
- twMDISysButtonNormal, twMDISysButtonHot, twMDISysButtonPushed, twMDISysButtonDisabled, twMDISysButtonInactive,
- twMinButtonNormal, twMinButtonHot, twMinButtonPushed, twMinButtonDisabled, twMinButtonInactive,
- twMDIMinButtonNormal, twMDIMinButtonHot, twMDIMinButtonPushed, twMDIMinButtonDisabled, twMDIMinButtonInactive,
- twMaxButtonNormal, twMaxButtonHot, twMaxButtonPushed, twMaxButtonDisabled, twMaxButtonInactive,
- twCloseButtonNormal, twCloseButtonHot, twCloseButtonPushed, twCloseButtonDisabled, twCloseButtonInactive,
- twSmallCloseButtonNormal, twSmallCloseButtonHot, twSmallCloseButtonPushed, twSmallCloseButtonDisabled, twSmallCloseButtonInactive,
- twMDICloseButtonNormal, twMDICloseButtonHot, twMDICloseButtonPushed, twMDICloseButtonDisabled, twMDICloseButtonInactive,
- twRestoreButtonNormal, twRestoreButtonHot, twRestoreButtonPushed, twRestoreButtonDisabled, twRestoreButtonInactive,
- twMDIRestoreButtonNormal, twMDIRestoreButtonHot, twMDIRestoreButtonPushed, twMDIRestoreButtonDisabled, twMDIRestoreButtonInactive,
- twHelpButtonNormal, twHelpButtonHot, twHelpButtonPushed, twHelpButtonDisabled, twHelpButtonInactive,
- twMDIHelpButtonNormal, twMDIHelpButtonHot, twMDIHelpButtonPushed, twMDIHelpButtonDisabled, twMDIHelpButtonInactive,
- twHorzScrollNormal, twHorzScrollHot, twHorzScrollPushed, twHorzScrollDisabled,
- twHorzThumbNormal, twHorzThumbHot, twHorzThumbPushed, twHorzThumbDisabled,
- twVertScrollNormal, twVertScrollHot, twVertScrollPushed, twVertScrollDisabled,
- twVertThumbNormal, twVertThumbHot, twVertThumbPushed, twVertThumbDisabled,
- twDialog,
- twCaptionSizingTemplate,
- twSmallCaptionSizingTemplate,
- twFrameLeftSizingTemplate,
- twSmallFrameLeftSizingTemplate,
- twFrameRightSizingTemplate,
- twSmallFrameRightSizingTemplate,
- twFrameBottomSizingTemplate,
- twSmallFrameBottomSizingTemplate
- );
- TThemeData = array[TThemedElement] of HTHEME;
- PThemedElementDetails = ^TThemedElementDetails;
- TThemedElementDetails = record
- Element: TThemedElement;
- Part,
- State: Integer;
- end;
- // TThemeServices is a small foot print class to provide the user with pure Windows XP theme related abilities like
- // painting elements and text or retrieving certain info.
- TThemeServices = class(TObject)
- private
- FThemesAvailable,
- FUseThemes,
- FControlsEnabled: Boolean;
- FWindowHandle: HWND;
- FDefWindowProc,
- FObjectInstance: Pointer;
- FThemeData: TThemeData; // Holds a list of theme data handles.
- FOnThemeChange: TNotifyEvent; // Called when the current window theme has changed.
- function GetTheme(Element: TThemedElement): HTHEME;
- function GetThemesEnabled: Boolean;
- procedure WindowProc(var Message: TMessage);
- protected
- procedure DoOnThemeChange; virtual;
- procedure UnloadThemeData;
- public
- constructor Create(ClientWindow: HWND);
- destructor Destroy; override;
- function GetElementDetails(Detail: TThemedButton): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedClock): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedComboBox): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedEdit): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedExplorerBar): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedHeader): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedListView): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedMenu): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedPage): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedProgress): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedRebar): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedScrollBar): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedSpin): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedStartPanel): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedStatus): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedTab): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedTaskBand): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedTaskBar): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedToolBar): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedToolTip): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedTrackBar): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedTrayNotify): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedTreeview): TThemedElementDetails; overload;
- function GetElementDetails(Detail: TThemedWindow): TThemedElementDetails; overload;
- function ColorToRGB(Color: TColor; Details: PThemedElementDetails = nil): COLORREF;
- function ContentRect(DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect;
- procedure DrawEdge(DC: HDC; Details: TThemedElementDetails; const R: TRect; Edge, Flags: Cardinal;
- ContentRect: PRect = nil);
- procedure DrawElement(DC: HDC; Details: TThemedElementDetails; const R: TRect; ClipRect: PRect = nil);
- procedure DrawIcon(DC: HDC; Details: TThemedElementDetails; const R: TRect; himl: HIMAGELIST; Index: Integer);
- procedure DrawParentBackground(Window: HWND; Target: HDC; Details: PThemedElementDetails; OnlyIfTransparent: Boolean;
- Bounds: PRect = nil);
- procedure DrawText(DC: HDC; Details: TThemedElementDetails; const S: WideString; R: TRect; Flags, Flags2: Cardinal);
- function HasTransparentParts(Details: TThemedElementDetails): Boolean;
- procedure PaintBorder(Control: TWinControl; EraseLRCorner: Boolean);
- procedure UpdateThemes;
- // MP
- function GetColor(Element: TThemedElement; PartId: Integer; StateId: Integer;
- PropId: Integer): TColor;
- property ClientWindow: HWND read FWindowHandle;
- property Theme[Element: TThemedElement]: HTHEME read GetTheme;
- property ThemesAvailable: Boolean read FThemesAvailable;
- property ThemesEnabled: Boolean read GetThemesEnabled;
- property OnThemeChange: TNotifyEvent read FOnThemeChange write FOnThemeChange;
- end;
- function ThemeServices: TThemeServices;
- //----------------------------------------------------------------------------------------------------------------------
- implementation
- uses
- Forms, // We need the application window to get notified about theme changes.
- SysUtils, ComCtrls;
- const
- // Do not modify the copyright in any way! Usage of this unit is prohibited without the copyright notice
- // in the compiled binary file.
- Copyright: string = 'Theme manager © 2001-2005 Mike Lischke';
- ThemeDataNames: array[TThemedElement] of PWideChar = (
- 'button', // teButton
- 'clock', // teClock
- 'combobox', // teComboBox
- 'edit', // teEdit
- 'explorerbar', // teExplorerBar
- 'header', // teHeader
- 'listview', // teListView
- 'menu', // teMenu
- 'page', // tePage
- 'progress', // teProgress
- 'rebar', // teRebar
- 'scrollbar', // teScrollBar
- 'spin', // teSpin
- 'startpanel', // teStartPanel
- 'status', // teStatus
- 'tab', // teTab
- 'taskband', // teTaskBand
- 'taskbar', // teTaskBar
- 'toolbar', // teToolBar
- 'tooltip', // teToolTip
- 'trackbar', // teTrackBar
- 'traynotify', // teTrayNotify
- 'treeview', // teTreeview
- 'window' // teWindow
- );
- var
- InternalThemeServices: TThemeServices;
- //----------------------------------------------------------------------------------------------------------------------
- function ThemeServices: TThemeServices;
- begin
- if InternalThemeServices = nil then
- InternalThemeServices := TThemeServices.Create(Application.Handle);
- Result := InternalThemeServices;
- end;
- //----------------- TThemeServices -------------------------------------------------------------------------------------
- constructor TThemeServices.Create(ClientWindow: HWND);
- begin
- FWindowHandle := ClientWindow;
- if FWindowHandle <> 0 then
- begin
- // If a window handle is given then subclass the window to get notified about theme changes.
- {$ifdef COMPILER_6_UP}
- FObjectInstance := Classes.MakeObjectInstance(WindowProc);
- {$else}
- FObjectInstance := MakeObjectInstance(WindowProc);
- {$endif COMPILER_6_UP}
- FDefWindowProc := Pointer(GetWindowLong(FWindowHandle, GWL_WNDPROC));
- SetWindowLong(FWindowHandle, GWL_WNDPROC, Integer(FObjectInstance));
- end;
- FThemesAvailable := InitThemeLibrary;
- UpdateThemes;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- destructor TThemeServices.Destroy;
- begin
- if Assigned(FObjectInstance) then
- begin
- SetWindowLong(FWindowHandle, GWL_WNDPROC, Integer(FDefWindowProc));
- {$ifdef COMPILER_6_UP}
- Classes.FreeObjectInstance(FObjectInstance);
- {$else}
- FreeObjectInstance(FObjectInstance);
- {$endif COMPILER_6_UP}
- end;
- UnloadThemeData;
- FreeThemeLibrary;
- inherited;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetTheme(Element: TThemedElement): HTHEME;
- // Returns the theme data handle for the given element. The theme is opened if not yet done.
- begin
- if FUseThemes and (FThemeData[Element] = 0) then
- begin
- FThemeData[Element] := OpenThemeData(FWindowHandle, ThemeDataNames[Element]);
- end;
- Result := FThemeData[Element];
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetThemesEnabled: Boolean;
- begin
- Result := FThemesAvailable and FUseThemes and FControlsEnabled;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- procedure TThemeServices.WindowProc(var Message: TMessage);
- begin
- case Message.Msg of
- WM_THEMECHANGED:
- begin
- // This message only appears if the services serve a particular window. If the services are part of some other theme
- // management structure (without an own window, e.g. in a TThemeManager class) then this structure is responsible to
- // call UpdateThemes explicitely.
- UpdateThemes;
- DoOnThemeChange;
- end;
- WM_DESTROY:
- begin
- // If we are connected to a window then we have to listen to its destruction.
- SetWindowLong(FWindowHandle, GWL_WNDPROC, Integer(FDefWindowProc));
- {$ifdef COMPILER_6_UP}
- Classes.FreeObjectInstance(FObjectInstance);
- {$else}
- FreeObjectInstance(FObjectInstance);
- {$endif COMPILER_6_UP}
- FObjectInstance := nil;
- end;
- end;
- with Message do
- Result := CallWindowProc(FDefWindowProc, FWindowHandle, Msg, WParam, LParam);
- end;
- //----------------------------------------------------------------------------------------------------------------------
- procedure TThemeServices.DoOnThemeChange;
- begin
- if Assigned(FOnThemeChange) then
- FOnThemeChange(Self);
- end;
- //----------------------------------------------------------------------------------------------------------------------
- procedure TThemeServices.UnloadThemeData;
- // Closes all opened theme data handles and frees the theme records.
- var
- Entry: TThemedElement;
- begin
- if (FWindowHandle = 0) or IsWindow(FWindowHandle) then
- begin
- for Entry := Low(TThemeData) to High(TThemeData) do
- if FThemeData[Entry] <> 0 then
- begin
- CloseThemeData(FThemeData[Entry]);
- FThemeData[Entry] := 0;
- end;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedButton): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teButton;
- with Result do
- begin
- case Detail of
- tbPushButtonNormal..tbPushButtonDefaulted:
- begin
- Part := BP_PUSHBUTTON;
- Base := Ord(tbPushButtonNormal);
- end;
- tbRadioButtonUncheckedNormal..tbRadioButtonCheckedDisabled:
- begin
- Part := BP_RADIOBUTTON;
- Base := Ord(tbRadioButtonUncheckedNormal);
- end;
- tbCheckBoxUncheckedNormal..tbCheckBoxMixedDisabled:
- begin
- Part := BP_CHECKBOX;
- Base := Ord(tbCheckBoxUncheckedNormal);
- end;
- tbGroupBoxNormal..tbGroupBoxDisabled:
- begin
- Part := BP_GROUPBOX;
- Base := Ord(tbGroupBoxNormal);
- end;
- tbUserButton:
- begin
- Part := BP_USERBUTTON;
- Base := Ord(tbUserButton);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedClock): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teClock;
- with Result do
- begin
- case Detail of
- tcTimeNormal:
- begin
- Part := CLP_TIME;
- Base := Ord(tcTimeNormal);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedComboBox): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teComboBox;
- with Result do
- begin
- case Detail of
- tcDropDownButtonNormal..tcDropDownButtonDisabled:
- begin
- Part := CP_DROPDOWNBUTTON;
- Base := Ord(tcDropDownButtonNormal);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedEdit): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teEdit;
- with Result do
- begin
- case Detail of
- teEditTextNormal..teEditTextAssist:
- begin
- Part := EP_EDITTEXT;
- Base := Ord(teEditTextNormal);
- end;
- teEditCaret:
- begin
- Part := EP_CARET;
- Base := Ord(teEditCaret);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedExplorerBar): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teExplorerBar;
- with Result do
- begin
- case Detail of
- tebHeaderBackgroundNormal..tebHeaderBackgroundPressed:
- begin
- Part := EBP_HEADERBACKGROUND;
- Base := Ord(tebHeaderBackgroundNormal);
- end;
- tebHeaderCloseNormal..tebHeaderClosePressed:
- begin
- Part := EBP_HEADERCLOSE;
- Base := Ord(tebHeaderCloseNormal);
- end;
- tebHeaderPinNormal..tebHeaderPinSelectedPressed:
- begin
- Part := EBP_HEADERPIN;
- Base := Ord(tebHeaderPinSelectedNormal);
- end;
- tebIEBarMenuNormal..tebIEBarMenuPressed:
- begin
- Part := EBP_IEBARMENU;
- Base := Ord(tebIEBarMenuNormal);
- end;
- tebNormalGroupBackground:
- begin
- Part := EBP_NORMALGROUPBACKGROUND;
- Base := Ord(tebNormalGroupBackground);
- end;
- tebNormalGroupCollapseNormal..tebNormalGroupCollapsePressed:
- begin
- Part := EBP_NORMALGROUPCOLLAPSE;
- Base := Ord(tebNormalGroupCollapseNormal);
- end;
- tebNormalGroupExpandNormal..tebNormalGroupExpandPressed:
- begin
- Part := EBP_NORMALGROUPEXPAND;
- Base := Ord(tebNormalGroupExpandNormal);
- end;
- tebNormalGroupHead:
- begin
- Part := EBP_NORMALGROUPHEAD;
- Base := Ord(tebNormalGroupHead);
- end;
- tebSpecialGroupBackground:
- begin
- Part := EBP_SPECIALGROUPBACKGROUND;
- Base := Ord(tebSpecialGroupBackground);
- end;
- tebSpecialGroupCollapseSpecial..tebSpecialGroupCollapsePressed:
- begin
- Part := EBP_SPECIALGROUPCOLLAPSE;
- Base := Ord(tebSpecialGroupCollapseSpecial);
- end;
- tebSpecialGroupExpandSpecial..tebSpecialGroupExpandPressed:
- begin
- Part := EBP_SPECIALGROUPEXPAND;
- Base := Ord(tebSpecialGroupExpandSpecial);
- end;
- tebSpecialGroupHead:
- begin
- Part := EBP_SPECIALGROUPHEAD;
- Base := Ord(tebSpecialGroupHead);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedHeader): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teHeader;
- with Result do
- begin
- case Detail of
- thHeaderItemNormal..thHeaderItemPressed:
- begin
- Part := HP_HEADERITEM;
- Base := Ord(thHeaderItemNormal);
- end;
- thHeaderItemLeftNormal..thHeaderItemLeftPressed:
- begin
- Part := HP_HEADERITEMLEFT;
- Base := Ord(thHeaderItemLeftNormal);
- end;
- thHeaderItemRightNormal..thHeaderItemRightPressed:
- begin
- Part := HP_HEADERITEMRIGHT;
- Base := Ord(thHeaderItemRightNormal);
- end;
- thHeaderSortArrowSortedUp..thHeaderSortArrowSortedDown:
- begin
- Part := HP_HEADERSORTARROW;
- Base := Ord(thHeaderSortArrowSortedUp);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedListview): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teListView;
- with Result do
- begin
- case Detail of
- tlListItemNormal..tlListItemSelectedNotFocus:
- begin
- Part := LVP_LISTITEM;
- Base := Ord(tlListItemNormal);
- end;
- tlListGroup:
- begin
- Part := LVP_LISTGROUP;
- Base := Ord(tlListGroup);
- end;
- tlListDetail:
- begin
- Part := LVP_LISTDETAIL;
- Base := Ord(tlListDetail);
- end;
- tlListSortDetail:
- begin
- Part := LVP_LISTSORTEDDETAIL;
- Base := Ord(tlListSortDetail);
- end;
- tlEmptyText:
- begin
- Part := LVP_EMPTYTEXT;
- Base := Ord(tlEmptyText);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedMenu): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teMenu;
- with Result do
- begin
- case Detail of
- tmMenuItemNormal..tmMenuItemDemoted:
- begin
- Part := MP_MENUITEM;
- Base := Ord(tmMenuItemNormal);
- end;
- tmMenuDropDown:
- begin
- Part := MP_MENUDROPDOWN;
- Base := Ord(tmMenuDropDown);
- end;
- tmMenuBarItem:
- begin
- Part := MP_MENUBARITEM;
- Base := Ord(tmMenuBarItem);
- end;
- tmMenuBarDropDown:
- begin
- Part := MP_MENUBARDROPDOWN;
- Base := Ord(tmMenuBarDropDown);
- end;
- tmChevron:
- begin
- Part := MP_CHEVRON;
- Base := Ord(tmChevron);
- end;
- tmSeparator:
- begin
- Part := MP_SEPARATOR;
- Base := Ord(tmSeparator);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedPage): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := tePage;
- with Result do
- begin
- case Detail of
- tpUpNormal..tpUpDisabled:
- begin
- Part := PGRP_UP;
- Base := Ord(tpUpNormal);
- end;
- tpDownNormal..tpDownDisabled:
- begin
- Part := PGRP_DOWN;
- Base := Ord(tpDownNormal);
- end;
- tpUpHorzNormal..tpUpHorzDisabled:
- begin
- Part := PGRP_UPHORZ;
- Base := Ord(tpUpHorzNormal);
- end;
- tpDownHorzNormal..tpDownHorzDisabled:
- begin
- Part := PGRP_DOWNHORZ;
- Base := Ord(tpDownHorzNormal);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedProgress): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teProgress;
- with Result do
- begin
- case Detail of
- tpBar:
- begin
- Part := PP_BAR;
- Base := Ord(tpBar);
- end;
- tpBarVert:
- begin
- Part := PP_BARVERT;
- Base := Ord(tpBarVert);
- end;
- tpChunk:
- begin
- Part := PP_CHUNK;
- Base := Ord(tpChunk);
- end;
- tpChunkVert:
- begin
- Part := PP_CHUNKVERT;
- Base := Ord(tpChunkVert);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedRebar): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teRebar;
- with Result do
- begin
- case Detail of
- trGripper:
- begin
- Part := RP_GRIPPER;
- Base := Ord(trGripper);
- end;
- trGripperVert:
- begin
- Part := RP_GRIPPERVERT;
- Base := Ord(trGripperVert);
- end;
- trBandNormal..trBandHotChecked:
- begin
- Part := RP_BAND;
- Base := Ord(trBandNormal);
- end;
- trChevronNormal..trChevronDisabled:
- begin
- Part := RP_CHEVRON;
- Base := Ord(trChevronNormal);
- end;
- trChevronVertNormal..trChevronVertDisabled:
- begin
- Part := RP_CHEVRONVERT;
- Base := Ord(trChevronVertNormal);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedScrollBar): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teScrollBar;
- with Result do
- begin
- case Detail of
- tsArrowBtnUpNormal..tsArrowBtnRightDisabled:
- begin
- Part := SBP_ARROWBTN;
- Base := Ord(tsArrowBtnUpNormal);
- end;
- tsThumbBtnHorzNormal..tsThumbBtnHorzDisabled:
- begin
- Part := SBP_THUMBBTNHORZ;
- Base := Ord(tsThumbBtnHorzNormal);
- end;
- tsThumbBtnVertNormal..tsThumbBtnVertDisabled:
- begin
- Part := SBP_THUMBBTNVERT;
- Base := Ord(tsThumbBtnVertNormal);
- end;
- tsLowerTrackHorzNormal..tsLowerTrackHorzDisabled:
- begin
- Part := SBP_LOWERTRACKHORZ;
- Base := Ord(tsLowerTrackHorzNormal);
- end;
- tsUpperTrackHorzNormal..tsUpperTrackHorzDisabled:
- begin
- Part := SBP_UPPERTRACKHORZ;
- Base := Ord(tsUpperTrackHorzNormal);
- end;
- tsLowerTrackVertNormal..tsLowerTrackVertDisabled:
- begin
- Part := SBP_LOWERTRACKVERT;
- Base := Ord(tsLowerTrackVertNormal);
- end;
- tsUpperTrackVertNormal..tsUpperTrackVertDisabled:
- begin
- Part := SBP_UPPERTRACKVERT;
- Base := Ord(tsUpperTrackVertNormal);
- end;
- tsGripperHorzNormal..tsGripperHorzDisabled:
- begin
- Part := SBP_GRIPPERHORZ;
- Base := Ord(tsGripperHorzNormal);
- end;
- tsGripperVertNormal..tsGripperVertDisabled:
- begin
- Part := SBP_GRIPPERVERT;
- Base := Ord(tsGripperVertNormal);
- end;
- tsSizeBoxRightAlign..tsSizeBoxLeftAlign:
- begin
- Part := SBP_SIZEBOX;
- Base := Ord(tsSizeBoxRightAlign);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedSpin): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teSpin;
- with Result do
- begin
- case Detail of
- tsUpNormal..tsUpDisabled:
- begin
- Part := SPNP_UP;
- Base := Ord(tsUpNormal);
- end;
- tsDownNormal..tsDownDisabled:
- begin
- Part := SPNP_DOWN;
- Base := Ord(tsDownNormal);
- end;
- tsUpHorzNormal..tsUpHorzDisabled:
- begin
- Part := SPNP_UPHORZ;
- Base := Ord(tsUpHorzNormal);
- end;
- tsDownHorzNormal..tsDownHorzDisabled:
- begin
- Part := SPNP_DOWNHORZ;
- Base := Ord(tsDownHorzNormal);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedStartPanel): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teStartPanel;
- with Result do
- begin
- case Detail of
- tspUserPane:
- begin
- Part := SPP_USERPANE;
- Base := Ord(tspUserPane);
- end;
- tspMorePrograms:
- begin
- Part := SPP_MOREPROGRAMS;
- Base := Ord(tspMorePrograms);
- end;
- tspMoreProgramsArrowNormal..tspMoreProgramsArrowPressed:
- begin
- Part := SPP_MOREPROGRAMSARROW;
- Base := Ord(tspMoreProgramsArrowNormal);
- end;
- tspProgList:
- begin
- Part := SPP_PROGLIST;
- Base := Ord(tspProgList);
- end;
- tspProgListSeparator:
- begin
- Part := SPP_PROGLISTSEPARATOR;
- Base := Ord(tspProgListSeparator);
- end;
- tspPlacesList:
- begin
- Part := SPP_PLACESLIST;
- Base := Ord(tspPlacesList);
- end;
- tspPlacesListSeparator:
- begin
- Part := SPP_PLACESLISTSEPARATOR;
- Base := Ord(tspPlacesListSeparator);
- end;
- tspLogOff:
- begin
- Part := SPP_LOGOFF;
- Base := Ord(tspLogOff);
- end;
- tspLogOffButtonsNormal..tspLogOffButtonsPressed:
- begin
- Part := SPP_LOGOFFBUTTONS;
- Base := Ord(tspLogOffButtonsNormal);
- end;
- tspUserPicture:
- begin
- Part := SPP_USERPICTURE;
- Base := Ord(tspUserPicture);
- end;
- tspPreview:
- begin
- Part := SPP_PREVIEW;
- Base := Ord(tspPreview);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedStatus): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teStatus;
- with Result do
- begin
- case Detail of
- tsPane:
- begin
- Part := SP_PANE;
- Base := Ord(tsPane);
- end;
- tsGripperPane:
- begin
- Part := SP_GRIPPERPANE;
- Base := Ord(tsGripperPane);
- end;
- tsGripper:
- begin
- Part := SP_GRIPPER;
- Base := Ord(tsGripper);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedTab): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teTab;
- with Result do
- begin
- case Detail of
- ttTabItemNormal..ttTabItemFocused:
- begin
- Part := TABP_TABITEM;
- Base := Ord(ttTabItemNormal);
- end;
- ttTabItemLeftEdgeNormal..ttTabItemLeftEdgeFocused:
- begin
- Part := TABP_TABITEMLEFTEDGE;
- Base := Ord(ttTabItemLeftEdgeNormal);
- end;
- ttTabItemRightEdgeNormal..ttTabItemRightEdgeFocused:
- begin
- Part := TABP_TABITEMRIGHTEDGE;
- Base := Ord(ttTabItemRightEdgeNormal);
- end;
- ttTabItemBothEdgeNormal..ttTabItemBothEdgeFocused:
- begin
- Part := TABP_TABITEMBOTHEDGE;
- Base := Ord(ttTabItemBothEdgeNormal);
- end;
- ttTopTabItemNormal..ttTopTabItemFocused:
- begin
- Part := TABP_TOPTABITEM;
- Base := Ord(ttTopTabItemNormal);
- end;
- ttTopTabItemLeftEdgeNormal..ttTopTabItemLeftEdgeFocused:
- begin
- Part := TABP_TOPTABITEMLEFTEDGE;
- Base := Ord(ttTopTabItemLeftEdgeNormal);
- end;
- ttTopTabItemRightEdgeNormal..ttTopTabItemRightEdgeFocused:
- begin
- Part := TABP_TOPTABITEMRIGHTEDGE;
- Base := Ord(ttTopTabItemRightEdgeNormal);
- end;
- ttTopTabItemBothEdgeNormal..ttTopTabItemBothEdgeFocused:
- begin
- Part := TABP_TOPTABITEMBOTHEDGE;
- Base := Ord(ttTopTabItemBothEdgeNormal);
- end;
- ttPane:
- begin
- Part := TABP_PANE;
- Base := Ord(ttPane);
- end;
- ttBody:
- begin
- Part := TABP_BODY;
- Base := Ord(ttBody);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedTaskBand): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teTaskBand;
- with Result do
- begin
- case Detail of
- ttbGroupCount:
- begin
- Part := TDP_GROUPCOUNT;
- Base := Ord(ttbGroupCount);
- end;
- ttbFlashButton:
- begin
- Part := TDP_FLASHBUTTON;
- Base := Ord(ttbFlashButton);
- end;
- ttpFlashButtonGroupMenu:
- begin
- Part := TDP_FLASHBUTTONGROUPMENU;
- Base := Ord(ttpFlashButtonGroupMenu);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedTaskBar): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teTaskBar;
- with Result do
- begin
- case Detail of
- ttbTimeNormal:
- begin
- Part := CLP_TIME;
- Base := Ord(ttbTimeNormal);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedToolBar): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teToolBar;
- with Result do
- begin
- case Detail of
- ttbButtonNormal..ttbButtonCheckedHot:
- begin
- Part := TP_BUTTON;
- Base := Ord(ttbButtonNormal);
- end;
- ttbDropDownButtonNormal..ttbDropDownButtonCheckedHot:
- begin
- Part := TP_DROPDOWNBUTTON;
- Base := Ord(ttbDropDownButtonNormal);
- end;
- ttbSplitButtonNormal..ttbSplitButtonCheckedHot:
- begin
- Part := TP_SPLITBUTTON;
- Base := Ord(ttbSplitButtonNormal);
- end;
- ttbSplitButtonDropDownNormal..ttbSplitButtonDropDownCheckedHot:
- begin
- Part := TP_SPLITBUTTONDROPDOWN;
- Base := Ord(ttbSplitButtonDropDownNormal);
- end;
- ttbSeparatorNormal..ttbSeparatorCheckedHot:
- begin
- Part := TP_SEPARATOR;
- Base := Ord(ttbSeparatorNormal);
- end;
- ttbSeparatorVertNormal..ttbSeparatorVertCheckedHot:
- begin
- Part := TP_SEPARATORVERT;
- Base := Ord(ttbSeparatorVertNormal);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedToolTip): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teToolTip;
- with Result do
- begin
- case Detail of
- tttStandardNormal..tttStandardLink:
- begin
- Part := TTP_STANDARD;
- Base := Ord(tttStandardNormal);
- end;
- tttStandardTitleNormal..tttStandardTitleLink:
- begin
- Part := TTP_STANDARDTITLE;
- Base := Ord(tttStandardTitleNormal);
- end;
- tttBaloonNormal..tttBaloonLink:
- begin
- Part := TTP_BALLOON;
- Base := Ord(tttBaloonNormal);
- end;
- tttBaloonTitleNormal..tttBaloonTitleLink:
- begin
- Part := TTP_BALLOONTITLE;
- Base := Ord(tttBaloonTitleNormal);
- end;
- tttCloseNormal..tttClosePressed:
- begin
- Part := TTP_CLOSE;
- Base := Ord(tttCloseNormal);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedTrackBar): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teTrackBar;
- with Result do
- begin
- case Detail of
- ttbTrack:
- begin
- Part := TKP_TRACK;
- Base := Ord(ttbTrack);
- end;
- ttbTrackVert:
- begin
- Part := TKP_TRACKVERT;
- Base := Ord(ttbTrackVert);
- end;
- ttbThumbNormal..ttbThumbDisabled:
- begin
- Part := TKP_THUMB;
- Base := Ord(ttbThumbNormal);
- end;
- ttbThumbBottomNormal..ttbThumbBottomDisabled:
- begin
- Part := TKP_THUMBBOTTOM;
- Base := Ord(ttbThumbBottomNormal);
- end;
- ttbThumbTopNormal..ttbThumbTopDisabled:
- begin
- Part := TKP_THUMBTOP;
- Base := Ord(ttbThumbTopNormal);
- end;
- ttbThumbVertNormal..ttbThumbVertDisabled:
- begin
- Part := TKP_THUMBVERT;
- Base := Ord(ttbThumbVertNormal);
- end;
- ttbThumbLeftNormal..ttbThumbLeftDisabled:
- begin
- Part := TKP_THUMBLEFT;
- Base := Ord(ttbThumbLeftNormal);
- end;
- ttbThumbRightNormal..ttbThumbRightDisabled:
- begin
- Part := TKP_THUMBRIGHT;
- Base := Ord(ttbThumbRightNormal);
- end;
- ttbThumbTics:
- begin
- Part := TKP_TICS;
- Base := Ord(ttbThumbTics);
- end;
- ttbThumbTicsVert:
- begin
- Part := TKP_TICSVERT;
- Base := Ord(ttbThumbTicsVert);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedTrayNotify): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teTrayNotify;
- with Result do
- begin
- case Detail of
- ttnBackground:
- begin
- Part := TNP_BACKGROUND;
- Base := Ord(ttnBackground);
- end;
- ttnAnimBackground:
- begin
- Part := TNP_ANIMBACKGROUND;
- Base := Ord(ttnAnimBackground);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedTreeview): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teTreeView;
- with Result do
- begin
- case Detail of
- ttItemNormal..ttItemSelectedNotFocus:
- begin
- Part := TVP_TREEITEM;
- Base := Ord(ttItemNormal);
- end;
- ttGlyphClosed..ttGlyphOpened:
- begin
- Part := TVP_GLYPH;
- Base := Ord(ttGlyphClosed);
- end;
- ttBranch:
- begin
- Part := TVP_BRANCH;
- Base := Ord(ttBranch);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.GetElementDetails(Detail: TThemedWindow): TThemedElementDetails;
- var
- Base: Integer;
- begin
- Result.Element := teWindow;
- with Result do
- begin
- case Detail of
- twCaptionActive..twCaptionDisabled:
- begin
- Part := WP_CAPTION;
- Base := Ord(twCaptionActive);
- end;
- twSmallCaptionActive..twSmallCaptionDisabled:
- begin
- Part := WP_SMALLCAPTION;
- Base := Ord(twSmallCaptionActive);
- end;
- twMinCaptionActive..twMinCaptionDisabled:
- begin
- Part := WP_MINCAPTION;
- Base := Ord(twMinCaptionActive);
- end;
- twSmallMinCaptionActive..twSmallMinCaptionDisabled:
- begin
- Part := WP_SMALLMINCAPTION;
- Base := Ord(twSmallMinCaptionActive);
- end;
- twMaxCaptionActive..twMaxCaptionDisabled:
- begin
- Part := WP_MAXCAPTION;
- Base := Ord(twMaxCaptionActive);
- end;
- twSmallMaxCaptionActive..twSmallMaxCaptionDisabled:
- begin
- Part := WP_SMALLMAXCAPTION;
- Base := Ord(twSmallMaxCaptionActive);
- end;
- twFrameLeftActive..twFrameLeftInactive:
- begin
- Part := WP_FRAMELEFT;
- Base := Ord(twFrameLeftActive);
- end;
- twFrameRightActive..twFrameRightInactive:
- begin
- Part := WP_FRAMERIGHT;
- Base := Ord(twFrameRightActive);
- end;
- twFrameBottomActive..twFrameBottomInactive:
- begin
- Part := WP_FRAMEBOTTOM;
- Base := Ord(twFrameBottomActive);
- end;
- twSmallFrameLeftActive..twSmallFrameLeftInactive:
- begin
- Part := WP_SMALLFRAMELEFT;
- Base := Ord(twSmallFrameLeftActive);
- end;
- twSmallFrameRightActive..twSmallFrameRightInactive:
- begin
- Part := WP_SMALLFRAMERIGHT;
- Base := Ord(twSmallFrameRightActive);
- end;
- twSmallFrameBottomActive..twSmallFrameBottomInactive:
- begin
- Part := WP_SMALLFRAMEBOTTOM;
- Base := Ord(twSmallFrameBottomActive);
- end;
- twSysButtonNormal..twSysButtonInactive:
- begin
- Part := WP_SYSBUTTON;
- Base := Ord(twSysButtonNormal);
- end;
- twMDISysButtonNormal..twMDISysButtonInactive:
- begin
- Part := WP_MDISYSBUTTON;
- Base := Ord(twMDISysButtonNormal);
- end;
- twMinButtonNormal..twMinButtonInactive:
- begin
- Part := WP_MINBUTTON;
- Base := Ord(twMinButtonNormal);
- end;
- twMDIMinButtonNormal..twMDIMinButtonInactive:
- begin
- Part := WP_MDIMINBUTTON;
- Base := Ord(twMDIMinButtonNormal);
- end;
- twMaxButtonNormal..twMaxButtonInactive:
- begin
- Part := WP_MAXBUTTON;
- Base := Ord(twMaxButtonNormal);
- end;
- twCloseButtonNormal..twCloseButtonInactive:
- begin
- Part := WP_CLOSEBUTTON;
- Base := Ord(twCloseButtonNormal);
- end;
- twSmallCloseButtonNormal..twSmallCloseButtonInactive:
- begin
- Part := WP_SMALLCLOSEBUTTON;
- Base := Ord(twSmallCloseButtonNormal);
- end;
- twMDICloseButtonNormal..twMDICloseButtonInactive:
- begin
- Part := WP_MDICLOSEBUTTON;
- Base := Ord(twMDICloseButtonNormal);
- end;
- twRestoreButtonNormal..twRestoreButtonInactive:
- begin
- Part := WP_RESTOREBUTTON;
- Base := Ord(twRestoreButtonNormal);
- end;
- twMDIRestoreButtonNormal..twMDIRestoreButtonInactive:
- begin
- Part := WP_MDIRESTOREBUTTON;
- Base := Ord(twMDIRestoreButtonNormal);
- end;
- twHelpButtonNormal..twHelpButtonInactive:
- begin
- Part := WP_HELPBUTTON;
- Base := Ord(twHelpButtonNormal);
- end;
- twMDIHelpButtonNormal..twMDIHelpButtonInactive:
- begin
- Part := WP_MDIHELPBUTTON;
- Base := Ord(twMDIHelpButtonNormal);
- end;
- twHorzScrollNormal..twHorzScrollDisabled:
- begin
- Part := WP_HORZSCROLL;
- Base := Ord(twHorzScrollNormal);
- end;
- twHorzThumbNormal..twHorzThumbDisabled:
- begin
- Part := WP_HORZTHUMB;
- Base := Ord(twHorzThumbNormal);
- end;
- twVertScrollNormal..twVertScrollDisabled:
- begin
- Part := WP_VERTSCROLL;
- Base := Ord(twVertScrollNormal);
- end;
- twVertThumbNormal..twVertThumbDisabled:
- begin
- Part := WP_VERTTHUMB;
- Base := Ord(twVertThumbNormal);
- end;
- twDialog:
- begin
- Part := WP_DIALOG;
- Base := Ord(twDialog);
- end;
- twCaptionSizingTemplate:
- begin
- Part := WP_CAPTIONSIZINGTEMPLATE;
- Base := Ord(twCaptionSizingTemplate);
- end;
- twSmallCaptionSizingTemplate:
- begin
- Part := WP_SMALLCAPTIONSIZINGTEMPLATE;
- Base := Ord(twSmallCaptionSizingTemplate);
- end;
- twFrameLeftSizingTemplate:
- begin
- Part := WP_FRAMELEFTSIZINGTEMPLATE;
- Base := Ord(twFrameLeftSizingTemplate);
- end;
- twSmallFrameLeftSizingTemplate:
- begin
- Part := WP_SMALLFRAMELEFTSIZINGTEMPLATE;
- Base := Ord(twSmallFrameLeftSizingTemplate);
- end;
- twFrameRightSizingTemplate:
- begin
- Part := WP_FRAMERIGHTSIZINGTEMPLATE;
- Base := Ord(twFrameRightSizingTemplate);
- end;
- twSmallFrameRightSizingTemplate:
- begin
- Part := WP_SMALLFRAMERIGHTSIZINGTEMPLATE;
- Base := Ord(twSmallFrameRightSizingTemplate);
- end;
- twFrameBottomSizingTemplate:
- begin
- Part := WP_FRAMEBOTTOMSIZINGTEMPLATE;
- Base := Ord(twFrameBottomSizingTemplate);
- end;
- twSmallFrameBottomSizingTemplate:
- begin
- Part := WP_SMALLFRAMEBOTTOMSIZINGTEMPLATE;
- Base := Ord(twSmallFrameBottomSizingTemplate);
- end;
- else
- Part := 0;
- Base := 0;
- end;
- State := Ord(Detail) - Base + 1;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.ColorToRGB(Color: TColor; Details: PThemedElementDetails = nil): COLORREF;
- begin
- if (Color and $80000000 = 0) or (Details = nil) then
- Result := Color
- else
- Result := GetThemeSysColor(Theme[Details.Element], Color and not $80000000);
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.ContentRect(DC: HDC; Details: TThemedElementDetails; BoundingRect: TRect): TRect;
- begin
- with Details do
- GetThemeBackgroundContentRect(Theme[Element], DC, Part, State, BoundingRect, @Result);
- end;
- //----------------------------------------------------------------------------------------------------------------------
- procedure TThemeServices.DrawEdge(DC: HDC; Details: TThemedElementDetails; const R: TRect; Edge, Flags: Cardinal;
- ContentRect: PRect = nil);
- begin
- with Details do
- DrawThemeEdge(Theme[Element], DC, Part, State, R, Edge, Flags, ContentRect);
- end;
- //----------------------------------------------------------------------------------------------------------------------
- procedure TThemeServices.DrawElement(DC: HDC; Details: TThemedElementDetails; const R: TRect; ClipRect: PRect = nil);
- begin
- with Details do
- DrawThemeBackground(Theme[Element], DC, Part, State, R, ClipRect);
- end;
- //----------------------------------------------------------------------------------------------------------------------
- procedure TThemeServices.DrawIcon(DC: HDC; Details: TThemedElementDetails; const R: TRect; himl: HIMAGELIST;
- Index: Integer);
- begin
- with Details do
- DrawThemeIcon(Theme[Element], DC, Part, State, R, himl, Index);
- end;
- //----------------------------------------------------------------------------------------------------------------------
- procedure TThemeServices.DrawParentBackground(Window: HWND; Target: HDC; Details: PThemedElementDetails;
- OnlyIfTransparent: Boolean; Bounds: PRect = nil);
- var
- DoDraw: Boolean;
- begin
- if OnlyIfTransparent and Assigned(Details) then
- begin
- with Details^ do
- DoDraw := IsThemeBackgroundPartiallyTransparent(Theme[Element], Part, State);
- end
- else
- DoDraw := True;
- if DoDraw then
- DrawThemeParentBackground(Window, Target, Bounds);
- end;
- //----------------------------------------------------------------------------------------------------------------------
- procedure TThemeServices.DrawText(DC: HDC; Details: TThemedElementDetails; const S: WideString; R: TRect; Flags,
- Flags2: Cardinal);
- begin
- with Details do
- DrawThemeText(Theme[Element], DC, Part, State, PWideChar(S), Length(S), Flags, Flags2, R);
- end;
- //----------------------------------------------------------------------------------------------------------------------
- function TThemeServices.HasTransparentParts(Details: TThemedElementDetails): Boolean;
- begin
- with Details do
- Result := IsThemeBackgroundPartiallyTransparent(Theme[Element], Part, State);
- end;
- //----------------------------------------------------------------------------------------------------------------------
- procedure TThemeServices.PaintBorder(Control: TWinControl; EraseLRCorner: Boolean);
- var
- EmptyRect,
- DrawRect: TRect;
- DC: HDC;
- H, W: Integer;
- AStyle,
- ExStyle: Integer;
- Details: TThemedElementDetails;
- begin
- with Control do
- begin
- ExStyle := GetWindowLong(Handle, GWL_EXSTYLE);
- if (ExStyle and WS_EX_CLIENTEDGE) <> 0 then
- begin
- GetWindowRect(Handle, DrawRect);
- OffsetRect(DrawRect, -DrawRect.Left, -DrawRect.Top);
- DC := GetWindowDC(Handle);
- try
- EmptyRect := DrawRect;
- if EraseLRCorner then
- begin
- AStyle := GetWindowLong(Handle, GWL_STYLE);
- if ((AStyle and WS_HSCROLL) <> 0) and ((AStyle and WS_VSCROLL) <> 0) then
- begin
- W := GetSystemMetrics(SM_CXVSCROLL);
- H := GetSystemMetrics(SM_CYHSCROLL);
- InflateRect(EmptyRect, -2, -2);
- with EmptyRect do
- EmptyRect := Rect(Right - W, Bottom - H, Right, Bottom);
- FillRect(DC, EmptyRect, GetSysColorBrush(COLOR_BTNFACE));
- end;
- end;
- with DrawRect do
- ExcludeClipRect(DC, Left + 2, Top + 2, Right - 2, Bottom - 2);
- Details := GetElementDetails(teEditTextNormal);
- DrawElement(DC, Details, DrawRect);
- finally
- ReleaseDC(Handle, DC);
- end;
- end;
- end;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- const
- ComCtlVersionIE6 = $00060000;
- procedure TThemeServices.UpdateThemes;
- var
- Flags: DWORD;
- begin
- if FUseThemes then
- UnloadThemeData;
- FUseThemes := UseThemes and (GetComCtlVersion >= ComCtlVersionIE6);
- if FUseThemes then
- begin
- Flags := GetThemeAppProperties;
- if (Flags and STAP_ALLOW_CONTROLS) = 0 then
- FControlsEnabled := False
- else
- FControlsEnabled := True;
- end
- else
- FControlsEnabled := False;
- end;
- //----------------------------------------------------------------------------------------------------------------------
- // MP BEGIN
- function TThemeServices.GetColor(Element: TThemedElement; PartId: Integer;
- StateId: Integer; PropId: Integer): TColor;
- var
- RGB: TColorRef;
- begin
- RGB := 0;
- GetThemeColor(Theme[Element], PartId, StateId, PropId, RGB);
- Result := RGB;
- end;
- // MP END
- //----------------------------------------------------------------------------------------------------------------------
- initialization
- finalization
- InternalThemeServices.Free;
- end.
|