Накидал примерчик. Перечисляет темы, и предлагает их установить. Под Vista не работает - дело в том, что реализация Theme Manager от Windows к Windows менялась. TLB для интерфейсов взял из XP SP1, а в XP SP2 эти интерфейсы закрыли, но оставили, поэтому решение не совсем стандартное. Насчет XP SP3 не знаю, думаю, сработает.  Вот TLB: | Код | unit Theme_TLB;
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
interface
uses Windows, ActiveX;
const // TypeLibrary Major and minor versions ThemeMajorVersion = 1; ThemeMinorVersion = 0;
LIBID_Theme: TGUID = '{40643250-8D23-47FB-895C-EAF48E2C8892}';
IID_ITheme: TGUID = '{A41C22EB-0F93-40AE-B7CE-37A4C4C81B01}'; IID_IThemeScheme: TGUID = '{AA49D906-65B2-42D6-A26A-2EE03C83F839}'; IID_IThemeStyle: TGUID = '{3672E804-D69D-43D8-AF58-F320B8D9AF32}'; IID_IThemeSize: TGUID = '{72DD2E7F-21E5-46DC-8847-CDDCF58B6725}'; IID_IThemeManager: TGUID = '{04D5D56C-EEAF-4419-B786-300284D6BB5F}'; CLASS_ThemeManager: TGUID = '{2E17C0EF-2851-459B-A3C8-27A41D4BC9F7}'; CLASS_Theme_: TGUID = '{F60691B4-3BD8-4F42-B2FD-20853C433A74}'; CLASS_ThemeScheme: TGUID = '{1C995F92-244F-48AC-9784-4AF9586EBBBA}'; CLASS_ThemeStyle: TGUID = '{AFCEFAC8-8097-4EE5-82DF-121202D95342}'; CLASS_ThemeSize: TGUID = '{05AF76AC-4245-468F-AE35-6D233436937A}'; IID_IThemePreview: TGUID = '{B63705F2-B2A2-401E-A20D-643E6B554A1D}'; IID_IPropertyBag: TGUID = '{55272A00-42CB-11CE-8135-00AA004BB851}'; IID_IErrorLog: TGUID = '{3127CA40-446E-11CE-8135-00AA004BB851}'; CLASS_ThemePreview: TGUID = '{B7BBD408-F09C-4AA8-B65E-A00B8FE0F0B9}';
// *********************************************************************// // Declaration of Enumerations defined in Type Library // *********************************************************************// // Constants for enum __MIDL_ITheme_0001 type __MIDL_ITheme_0001 = TOleEnum; const BKDGT_CENTER = $00000000; BKDGT_TILE = $00000001; BKDGT_STRECH = $00000002;
// Constants for enum __MIDL_IThemeSize_0002 type __MIDL_IThemeSize_0002 = TOleEnum; const SMS_BORDERWIDTH = $00000000; SMS_SCROLLWIDTH = $00000001; SMS_SCROLLHEIGHT = $00000002; SMS_CAPTIONWIDTH = $00000003; SMS_CAPTIONHEIGHT = $00000004; SMS_SMCAPTIONWIDTH = $00000005; SMS_SMCAPTIONHEIGHT = $00000006; SMS_MENUWIDTH = $00000007; SMS_MENUHEIGHT = $00000008;
// Constants for enum __MIDL_IThemeSize_0003 type __MIDL_IThemeSize_0003 = TOleEnum; const CONTRAST_NORMAL = $00000000; CONTRAST_HIGHBLACK = $00000001; CONTRAST_HIGHWHITE = $00000002;
// Constants for enum __MIDL_IThemeSize_0001 type __MIDL_IThemeSize_0001 = TOleEnum; const SMF_CAPTIONFONT = $00000000; SMF_SMCAPTIONFONT = $00000001; SMF_MENUFONT = $00000002; SMF_ICONTITLEFONT = $00000003; SMF_STATUSFONT = $00000004; SMF_MESSAGEFONT = $00000005;
type
// *********************************************************************// // Forward declaration of types defined in TypeLibrary // *********************************************************************// ITheme = interface; IThemeDisp = dispinterface; IThemeScheme = interface; IThemeSchemeDisp = dispinterface; IThemeStyle = interface; IThemeStyleDisp = dispinterface; IThemeSize = interface; IThemeSizeDisp = dispinterface; IThemeManager = interface; IThemeManagerDisp = dispinterface; IThemePreview = interface; IThemePreviewDisp = dispinterface; IPropertyBag = interface; IErrorLog = interface;
// *********************************************************************// // Declaration of CoClasses defined in Type Library // (NOTE: Here we map each CoClass to its Default Interface) // *********************************************************************// ThemeManager = IThemeManager; Theme_ = ITheme; ThemeScheme = IThemeScheme; ThemeStyle = IThemeStyle; ThemeSize = IThemeSize; ThemePreview = IThemePreview;
// *********************************************************************// // Declaration of structures, unions and aliases. // *********************************************************************// wireHWND = ^TGUID; PUserType1 = ^LOGFONTW; {*} POleVariant1 = ^OleVariant; {*} PUserType2 = ^TGUID; {*}
enumBkgdTile = __MIDL_ITheme_0001; enumSystemMetricSize = __MIDL_IThemeSize_0002; enumThemeContrastLevels = __MIDL_IThemeSize_0003; enumSystemMetricFont = __MIDL_IThemeSize_0001;
__MIDL___MIDL_itf_theme_0253_0004 = packed record lfHeight: Integer; lfWidth: Integer; lfEscapement: Integer; lfOrientation: Integer; lfWeight: Integer; lfItalic: Byte; lfUnderline: Byte; lfStrikeOut: Byte; lfCharSet: Byte; lfOutPrecision: Byte; lfClipPrecision: Byte; lfQuality: Byte; lfPitchAndFamily: Byte; lfFaceName: array[0..31] of Word; end;
LOGFONTW = TGUID;
__MIDL_IWinTypes_0009 = record case Integer of 0: (hInproc: Integer); 1: (hRemote: Integer); end;
_RemotableHandle = packed record fContext: Integer; u: __MIDL_IWinTypes_0009; end;
// *********************************************************************// // Interface: ITheme // Flags: (4544) Dual NonExtensible OleAutomation Dispatchable // GUID: {A41C22EB-0F93-40AE-B7CE-37A4C4C81B01} // *********************************************************************// ITheme = interface(IDispatch) ['{A41C22EB-0F93-40AE-B7CE-37A4C4C81B01}'] function Get_DisplayName: WideString; safecall; procedure Set_DisplayName(const pbstrDisplayName: WideString); safecall; function Get_Background: WideString; safecall; procedure Set_Background(const pbstrPath: WideString); safecall; function Get_BackgroundTile: enumBkgdTile; safecall; procedure Set_BackgroundTile(pnTile: enumBkgdTile); safecall; function Get_ScreenSaver: WideString; safecall; procedure Set_ScreenSaver(const pbstrPath: WideString); safecall; function Get_VisualStyle: WideString; safecall; procedure Set_VisualStyle(const pbstrPath: WideString); safecall; function Get_VisualStyleColor: WideString; safecall; procedure Set_VisualStyleColor(const pbstrPath: WideString); safecall; function Get_VisualStyleSize: WideString; safecall; procedure Set_VisualStyleSize(const pbstrPath: WideString); safecall; function GetPath(fExpand: WordBool): WideString; safecall; procedure SetPath(const bstrPath: WideString); safecall; function GetCursor(const bstrCursor: WideString): WideString; safecall; procedure SetCursor(const bstrCursor: WideString; const bstrPath: WideString); safecall; function GetSound(const bstrSoundName: WideString): WideString; safecall; procedure SetSound(const bstrSoundName: WideString; const bstrPath: WideString); safecall; function GetIcon(const bstrIconName: WideString): WideString; safecall; procedure SetIcon(const bstrIconName: WideString; const bstrIconPath: WideString); safecall; property DisplayName: WideString read Get_DisplayName write Set_DisplayName; property Background: WideString read Get_Background write Set_Background; property BackgroundTile: enumBkgdTile read Get_BackgroundTile write Set_BackgroundTile; property ScreenSaver: WideString read Get_ScreenSaver write Set_ScreenSaver; property VisualStyle: WideString read Get_VisualStyle write Set_VisualStyle; property VisualStyleColor: WideString read Get_VisualStyleColor write Set_VisualStyleColor; property VisualStyleSize: WideString read Get_VisualStyleSize write Set_VisualStyleSize; end;
// *********************************************************************// // DispIntf: IThemeDisp // Flags: (4544) Dual NonExtensible OleAutomation Dispatchable // GUID: {A41C22EB-0F93-40AE-B7CE-37A4C4C81B01} // *********************************************************************// IThemeDisp = dispinterface ['{A41C22EB-0F93-40AE-B7CE-37A4C4C81B01}'] property DisplayName: WideString dispid 200; property Background: WideString dispid 201; property BackgroundTile: enumBkgdTile dispid 202; property ScreenSaver: WideString dispid 203; property VisualStyle: WideString dispid 252; property VisualStyleColor: WideString dispid 253; property VisualStyleSize: WideString dispid 254; function GetPath(fExpand: WordBool): WideString; dispid 250; procedure SetPath(const bstrPath: WideString); dispid 251; function GetCursor(const bstrCursor: WideString): WideString; dispid 255; procedure SetCursor(const bstrCursor: WideString; const bstrPath: WideString); dispid 256; function GetSound(const bstrSoundName: WideString): WideString; dispid 257; procedure SetSound(const bstrSoundName: WideString; const bstrPath: WideString); dispid 258; function GetIcon(const bstrIconName: WideString): WideString; dispid 259; procedure SetIcon(const bstrIconName: WideString; const bstrIconPath: WideString); dispid 260; end;
// *********************************************************************// // Interface: IThemeScheme // Flags: (4544) Dual NonExtensible OleAutomation Dispatchable // GUID: {AA49D906-65B2-42D6-A26A-2EE03C83F839} // *********************************************************************// IThemeScheme = interface(IDispatch) ['{AA49D906-65B2-42D6-A26A-2EE03C83F839}'] function Get_DisplayName: WideString; safecall; procedure Set_DisplayName(const pbstrDisplayName: WideString); safecall; function Get_Path: WideString; safecall; procedure Set_Path(const pbstrPath: WideString); safecall; function Get_length: Integer; safecall; function Get_item(varIndex: OleVariant): IThemeStyle; safecall; function Get_SelectedStyle: IThemeStyle; safecall; procedure Set_SelectedStyle(const ppThemeStyle: IThemeStyle); safecall; function AddStyle: IThemeStyle; safecall; property DisplayName: WideString read Get_DisplayName write Set_DisplayName; property Path: WideString read Get_Path write Set_Path; property length: Integer read Get_length; property item[varIndex: OleVariant]: IThemeStyle read Get_item; property SelectedStyle: IThemeStyle read Get_SelectedStyle write Set_SelectedStyle; end;
// *********************************************************************// // DispIntf: IThemeSchemeDisp // Flags: (4544) Dual NonExtensible OleAutomation Dispatchable // GUID: {AA49D906-65B2-42D6-A26A-2EE03C83F839} // *********************************************************************// IThemeSchemeDisp = dispinterface ['{AA49D906-65B2-42D6-A26A-2EE03C83F839}'] property DisplayName: WideString dispid 301; property Path: WideString dispid 302; property length: Integer readonly dispid 303; property item[varIndex: OleVariant]: IThemeStyle readonly dispid 304; property SelectedStyle: IThemeStyle dispid 305; function AddStyle: IThemeStyle; dispid 350; end;
// *********************************************************************// // Interface: IThemeStyle // Flags: (4544) Dual NonExtensible OleAutomation Dispatchable // GUID: {3672E804-D69D-43D8-AF58-F320B8D9AF32} // *********************************************************************// IThemeStyle = interface(IDispatch) ['{3672E804-D69D-43D8-AF58-F320B8D9AF32}'] function Get_DisplayName: WideString; safecall; procedure Set_DisplayName(const pbstrDisplayName: WideString); safecall; function Get_Name: WideString; safecall; procedure Set_Name(const pbstrName: WideString); safecall; function Get_length: Integer; safecall; function Get_item(varIndex: OleVariant): IThemeSize; safecall; function Get_SelectedSize: IThemeSize; safecall; procedure Set_SelectedSize(const ppThemeSize: IThemeSize); safecall; function AddSize: IThemeSize; safecall; property DisplayName: WideString read Get_DisplayName write Set_DisplayName; property Name: WideString read Get_Name write Set_Name; property length: Integer read Get_length; property item[varIndex: OleVariant]: IThemeSize read Get_item; property SelectedSize: IThemeSize read Get_SelectedSize write Set_SelectedSize; end;
// *********************************************************************// // DispIntf: IThemeStyleDisp // Flags: (4544) Dual NonExtensible OleAutomation Dispatchable // GUID: {3672E804-D69D-43D8-AF58-F320B8D9AF32} // *********************************************************************// IThemeStyleDisp = dispinterface ['{3672E804-D69D-43D8-AF58-F320B8D9AF32}'] property DisplayName: WideString dispid 400; property Name: WideString dispid 401; property length: Integer readonly dispid 402; property item[varIndex: OleVariant]: IThemeSize readonly dispid 403; property SelectedSize: IThemeSize dispid 404; function AddSize: IThemeSize; dispid 450; end;
// *********************************************************************// // Interface: IThemeSize // Flags: (4544) Dual NonExtensible OleAutomation Dispatchable // GUID: {72DD2E7F-21E5-46DC-8847-CDDCF58B6725} // *********************************************************************// IThemeSize = interface(IDispatch) ['{72DD2E7F-21E5-46DC-8847-CDDCF58B6725}'] function Get_DisplayName: WideString; safecall; procedure Set_DisplayName(const pbstrDisplayName: WideString); safecall; function Get_Name: WideString; safecall; procedure Set_Name(const pbstrName: WideString); safecall; function Get_SystemMetricColor(nSysColorIndex: SYSINT): LongWord; safecall; procedure Set_SystemMetricColor(nSysColorIndex: SYSINT; pColorRef: LongWord); safecall; function Get_SystemMetricSize(nSystemMetricIndex: enumSystemMetricSize): SYSINT; safecall; procedure Set_SystemMetricSize(nSystemMetricIndex: enumSystemMetricSize; pnSize: SYSINT); safecall; function Get_WebviewCSS: WideString; safecall; function Get_ContrastLevel: enumThemeContrastLevels; safecall; procedure Set_ContrastLevel(pContrastLevel: enumThemeContrastLevels); safecall; procedure GetSystemMetricFont(nFontIndex: enumSystemMetricFont; var pLogFontW: LOGFONTW); safecall; procedure PutSystemMetricFont(nFontIndex: enumSystemMetricFont; var pLogFontW: LOGFONTW); safecall; property DisplayName: WideString read Get_DisplayName write Set_DisplayName; property Name: WideString read Get_Name write Set_Name; property SystemMetricColor[nSysColorIndex: SYSINT]: LongWord read Get_SystemMetricColor write Set_SystemMetricColor; property SystemMetricSize[nSystemMetricIndex: enumSystemMetricSize]: SYSINT read Get_SystemMetricSize write Set_SystemMetricSize; property WebviewCSS: WideString read Get_WebviewCSS; property ContrastLevel: enumThemeContrastLevels read Get_ContrastLevel write Set_ContrastLevel; end;
// *********************************************************************// // DispIntf: IThemeSizeDisp // Flags: (4544) Dual NonExtensible OleAutomation Dispatchable // GUID: {72DD2E7F-21E5-46DC-8847-CDDCF58B6725} // *********************************************************************// IThemeSizeDisp = dispinterface ['{72DD2E7F-21E5-46DC-8847-CDDCF58B6725}'] property DisplayName: WideString dispid 500; property Name: WideString dispid 501; property SystemMetricColor[nSysColorIndex: SYSINT]: LongWord dispid 502; property SystemMetricSize[nSystemMetricIndex: enumSystemMetricSize]: SYSINT dispid 503; property WebviewCSS: WideString readonly dispid 504; property ContrastLevel: enumThemeContrastLevels dispid 505; procedure GetSystemMetricFont(nFontIndex: enumSystemMetricFont; var pLogFontW: {??LOGFONTW} OleVariant); dispid 550; procedure PutSystemMetricFont(nFontIndex: enumSystemMetricFont; var pLogFontW: {??LOGFONTW} OleVariant); dispid 551; end;
// *********************************************************************// // Interface: IThemeManager // Flags: (4544) Dual NonExtensible OleAutomation Dispatchable // GUID: {04D5D56C-EEAF-4419-B786-300284D6BB5F} // *********************************************************************// IThemeManager = interface(IDispatch) ['{04D5D56C-EEAF-4419-B786-300284D6BB5F}'] function Get_length: Integer; safecall; function Get_item(varIndex: OleVariant): ITheme; safecall; function Get_schemeLength: Integer; safecall; function Get_schemeItem(varIndex: OleVariant): IThemeScheme; safecall; function Get_WebviewCSS: WideString; safecall; function Get_SelectedTheme: ITheme; safecall; procedure Set_SelectedTheme(const ppTheme: ITheme); safecall; function Get_SelectedScheme: IThemeScheme; safecall; procedure Set_SelectedScheme(const ppThemeScheme: IThemeScheme); safecall; function GetSpecialTheme(const bstrName: WideString): ITheme; safecall; procedure SetSpecialTheme(const bstrName: WideString; const pTheme: ITheme); safecall; function GetSpecialScheme(const bstrName: WideString; out ppThemeScheme: IThemeScheme; out ppThemeStyle: IThemeStyle): IThemeSize; safecall; procedure SetSpecialScheme(const bstrName: WideString; const pThemeScheme: IThemeScheme; const pThemeStyle: IThemeStyle; const pThemeSize: IThemeSize); safecall; function GetSelectedSchemeProperty(const bstrName: WideString): WideString; safecall; procedure ApplyNow; safecall; property Length: Integer read Get_length; property Item[varIndex: OleVariant]: ITheme read Get_item; property SchemeLength: Integer read Get_schemeLength; property SchemeItem[varIndex: OleVariant]: IThemeScheme read Get_schemeItem; property WebviewCSS: WideString read Get_WebviewCSS; property SelectedTheme: ITheme read Get_SelectedTheme write Set_SelectedTheme; property SelectedScheme: IThemeScheme read Get_SelectedScheme write Set_SelectedScheme; end;
// *********************************************************************// // DispIntf: IThemeManagerDisp // Flags: (4544) Dual NonExtensible OleAutomation Dispatchable // GUID: {04D5D56C-EEAF-4419-B786-300284D6BB5F} // *********************************************************************// IThemeManagerDisp = dispinterface ['{04D5D56C-EEAF-4419-B786-300284D6BB5F}'] property length: Integer readonly dispid 101; property item[varIndex: OleVariant]: ITheme readonly dispid 102; property schemeLength: Integer readonly dispid 105; property schemeItem[varIndex: OleVariant]: IThemeScheme readonly dispid 106; property WebviewCSS: WideString readonly dispid 104; property SelectedTheme: ITheme dispid 100; property SelectedScheme: IThemeScheme dispid 103; function GetSpecialTheme(const bstrName: WideString): ITheme; dispid 151; procedure SetSpecialTheme(const bstrName: WideString; const pTheme: ITheme); dispid 152; function GetSpecialScheme(const bstrName: WideString; out ppThemeScheme: IThemeScheme; out ppThemeStyle: IThemeStyle): IThemeSize; dispid 153; procedure SetSpecialScheme(const bstrName: WideString; const pThemeScheme: IThemeScheme; const pThemeStyle: IThemeStyle; const pThemeSize: IThemeSize); dispid 154; function GetSelectedSchemeProperty(const bstrName: WideString): WideString; dispid 150; procedure ApplyNow; dispid 155; end;
// *********************************************************************// // Interface: IThemePreview // Flags: (448) Dual NonExtensible OleAutomation // GUID: {B63705F2-B2A2-401E-A20D-643E6B554A1D} // *********************************************************************// IThemePreview = interface(IUnknown) ['{B63705F2-B2A2-401E-A20D-643E6B554A1D}'] procedure UpdatePreview(const pPropertyBag: IPropertyBag); safecall; procedure CreatePreview(var hwndParent: TGUID; dwFlags: LongWord; dwStyle: LongWord; dwExStyle: LongWord; x: SYSINT; y: SYSINT; nWidth: SYSINT; nHeight: SYSINT; const pPropertyBag: IPropertyBag; dwCtrlID: LongWord); safecall; end;
// *********************************************************************// // DispIntf: IThemePreviewDisp // Flags: (448) Dual NonExtensible OleAutomation // GUID: {B63705F2-B2A2-401E-A20D-643E6B554A1D} // *********************************************************************// IThemePreviewDisp = dispinterface ['{B63705F2-B2A2-401E-A20D-643E6B554A1D}'] procedure UpdatePreview(const pPropertyBag: IPropertyBag); dispid 650; procedure CreatePreview(var hwndParent: {??TGUID} OleVariant; dwFlags: LongWord; dwStyle: LongWord; dwExStyle: LongWord; x: SYSINT; y: SYSINT; nWidth: SYSINT; nHeight: SYSINT; const pPropertyBag: IPropertyBag; dwCtrlID: LongWord); dispid 651; end;
// *********************************************************************// // Interface: IPropertyBag // Flags: (0) // GUID: {55272A00-42CB-11CE-8135-00AA004BB851} // *********************************************************************// IPropertyBag = interface(IUnknown) ['{55272A00-42CB-11CE-8135-00AA004BB851}'] function RemoteRead(pszPropName: PWideChar; out pVar: OleVariant; const pErrorLog: IErrorLog; varType: LongWord; const pUnkObj: IUnknown): HResult; stdcall; function Write(pszPropName: PWideChar; var pVar: OleVariant): HResult; stdcall; end;
// *********************************************************************// // Interface: IErrorLog // Flags: (0) // GUID: {3127CA40-446E-11CE-8135-00AA004BB851} // *********************************************************************// IErrorLog = interface(IUnknown) ['{3127CA40-446E-11CE-8135-00AA004BB851}'] function AddError(pszPropName: PWideChar; var pExcepInfo: TGUID): HResult; stdcall; end;
implementation
end.
|
А вот сам пример: | Код | unit Unit1;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComObj, ActiveX, Theme_TLB;
type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject); var Manager: IThemeManager; Theme: ITheme; I: Integer; begin if Succeeded(CoCreateInstance(CLASS_ThemeManager, nil, CLSCTX_ALL, IID_IThemeManager, Manager)) then try for I := 0 to Manager.Length - 1 do begin Theme := Manager.Item[I]; if Assigned(Theme) then try case MessageBox(Handle, PChar('Применить тему "' + String(Theme.DisplayName) + '" ?'), 'Theme', MB_ICONQUESTION or MB_YESNO) of IDYES: with Manager do begin { Выбор темы } SelectedTheme := Theme; { Применение темы } ApplyNow; Break; end; IDNO: Continue; end; finally Theme := nil; end; end; finally Manager := nil; end; end;
end.
|
Присоединённый файл ( Кол-во скачиваний: 19 )
Themes.rar 16,03 Kb
|