📄 themesrv.pas
字号:
// '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;
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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -