RVXPTheme.pas
上传用户:daoqigc
上传日期:2021-04-20
资源大小:2795k
文件大小:5k
源码类别:

RichEdit

开发平台:

Delphi

  1. {*******************************************************}
  2. {                                                       }
  3. {       RichView                                        }
  4. {       Windows XP Themes API                           }
  5. {       (only functions required for RichView)          }
  6. {                                                       }
  7. {       Copyright (c) Sergey Tkachenko                  }
  8. {       svt@trichview.com                               }
  9. {       http://www.trichview.com                        }
  10. {                                                       }
  11. {*******************************************************}
  12. unit RVXPTheme;
  13. interface
  14. {$I RV_Defs.inc}
  15. uses SysUtils, Windows;
  16. type
  17.   HTheme = Cardinal;
  18.   RV_IsThemeActiveProc = function : boolean; stdcall;
  19.   RV_IsAppThemedProc =  function: boolean; stdcall;
  20.   RV_OpenThemeDataProc = function (hwnd : HWND; pszClassList : PWideChar) : HTheme; stdcall;
  21.   RV_CloseThemeDataProc= function (Theme : HTheme) : HRESULT; stdcall;
  22.   RV_DrawThemeParentBackgroundProc = function (hwnd : HWND; hdc : HDC; Rect : PRect) : HRESULT; stdcall;
  23.   RV_DrawThemeEdgeProc = function(Theme : HTheme; hdc : HDC;
  24.     iPartId, iStateId: Integer; const pDestRect: TRect; uEdge, uFlags: UINT;
  25.     pContentRect: PRect): HRESULT; stdcall;
  26.   RV_DrawThemeBackgroundProc = function (Theme : HTheme; hdc : HDC;
  27.     iPartId : integer; iStateId : integer; const Rect : TRect; {OPTIONAL} pClipRect : PRect) : HRESULT; stdcall;
  28.   RV_DrawThemeTextProc = function (Theme : HTheme; hdc : HDC; iPartId, iStateId : integer;
  29.     pszText : PWideChar; iCharCount : integer; dwTextFlags : DWORD;
  30.     dwTextFlags2 : DWORD; var Rect : TRect) : HRESULT; stdcall;
  31.   RV_IsThemeBackgroundPartiallyTransparentProc =
  32.     function(hTheme: HTheme; iPartId, iStateId: Integer): Boolean; stdcall;
  33. var
  34.   RV_IsThemeActive: RV_IsThemeActiveProc;
  35.   RV_IsAppThemed: RV_IsAppThemedProc;
  36.   RV_OpenThemeData: RV_OpenThemeDataProc;
  37.   RV_CloseThemeData: RV_CloseThemeDataProc;
  38.   RV_DrawThemeParentBackground: RV_DrawThemeParentBackgroundProc;
  39.   RV_DrawThemeEdge: RV_DrawThemeEdgeProc;
  40.   RV_DrawThemeBackground: RV_DrawThemeBackgroundProc;
  41.   RV_DrawThemeText: RV_DrawThemeTextProc;
  42.   RV_IsThemeBackgroundPartiallyTransparent: RV_IsThemeBackgroundPartiallyTransparentProc;
  43. const
  44.   WM_THEMECHANGED          = $031A;
  45.   EP_EDITTEXT              = 1;
  46.   ETS_NORMAL               = 1;
  47.   ETS_HOT                  = 2;
  48.   ETS_SELECTED             = 3;
  49.   ETS_DISABLED             = 4;
  50.   ETS_FOCUSED              = 5;
  51.   ETS_READONLY             = 6;
  52.   ETS_ASSIST               = 7;
  53.   BP_RADIOBUTTON          = 2;
  54.   RBS_UNCHECKEDNORMAL     = 1;
  55.   RBS_UNCHECKEDHOT        = 2;
  56.   RBS_UNCHECKEDPRESSED    = 3;
  57.   RBS_UNCHECKEDDISABLED   = 4;
  58.   RBS_CHECKEDNORMAL       = 5;
  59.   RBS_CHECKEDHOT          = 6;
  60.   RBS_CHECKEDPRESSED      = 7;
  61.   RBS_CHECKEDDISABLED     = 8;
  62.   BP_CHECKBOX             = 3;
  63.   CBS_UNCHECKEDNORMAL     = 1;
  64.   CBS_UNCHECKEDHOT        = 2;
  65.   CBS_UNCHECKEDPRESSED    = 3;
  66.   CBS_UNCHECKEDDISABLED   = 4;
  67.   CBS_CHECKEDNORMAL       = 5;
  68.   CBS_CHECKEDHOT          = 6;
  69.   CBS_CHECKEDPRESSED      = 7;
  70.   CBS_CHECKEDDISABLED     = 8;
  71.   CBS_MIXEDNORMAL         = 9;
  72.   CBS_MIXEDHOT            = 10;
  73.   CBS_MIXEDPRESSED        = 11;
  74.   CBS_MIXEDDISABLED       = 12;
  75.   BP_GROUPBOX             = 4;
  76.   GBS_NORMAL              = 1;
  77.   GBS_DISABLED            = 2;
  78.   CP_DROPDOWNBUTTON        = 1;
  79.   CBXS_NORMAL              = 1;
  80.   CBXS_HOT                 = 2;
  81.   CBXS_PRESSED             = 3;
  82.   CBXS_DISABLED            = 4;
  83. implementation
  84. var hThemeLib: HINST;
  85. procedure Init;
  86. begin
  87.   hThemeLib := 0;
  88.   if (Win32Platform  = VER_PLATFORM_WIN32_NT)
  89.      {$IFDEF RICHVIEWCBDEF3}
  90.       and
  91.      (((Win32MajorVersion = 5) and (Win32MinorVersion >= 1)) or
  92.       (Win32MajorVersion > 5))
  93.      {$ENDIF}
  94.       then
  95.   begin
  96.     RV_IsThemeActive := nil;
  97.     RV_IsAppThemed := nil;
  98.     RV_OpenThemeData := nil;
  99.     RV_CloseThemeData := nil;
  100.     RV_DrawThemeParentBackground := nil;
  101.     RV_DrawThemeText := nil;
  102.     RV_DrawThemeEdge := nil;
  103.     RV_DrawThemeBackground := nil;
  104.     RV_IsThemeBackgroundPartiallyTransparent := nil;
  105.     hThemeLib := LoadLibrary('uxtheme.dll');
  106.     if hThemeLib <> 0 then
  107.     begin
  108.       RV_IsThemeActive := GetProcAddress(hThemeLib, 'IsThemeActive');
  109.       RV_IsAppThemed   := GetProcAddress(hThemeLib, 'IsAppThemed');
  110.       RV_OpenThemeData := GetProcAddress(hThemeLib, 'OpenThemeData');
  111.       RV_CloseThemeData := GetProcAddress(hThemeLib, 'CloseThemeData');
  112.       RV_DrawThemeParentBackground := GetProcAddress(hThemeLib, 'DrawThemeParentBackground');
  113.       RV_DrawThemeText := GetProcAddress(hThemeLib, 'DrawThemeText');
  114.       RV_DrawThemeEdge := GetProcAddress(hThemeLib, 'DrawThemeEdge');
  115.       RV_DrawThemeBackground := GetProcAddress(hThemeLib, 'DrawThemeBackground');
  116.       RV_IsThemeBackgroundPartiallyTransparent := GetProcAddress(hThemeLib, 'IsThemeBackgroundPartiallyTransparent');
  117.     end;
  118.   end;
  119. end;
  120. initialization
  121.   Init;
  122. finalization
  123.   if hThemeLib <> 0 then
  124.     FreeLibrary(hThemeLib);
  125. end.