⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dxuxtheme.pas

📁 胜天进销存源码,国产优秀的进销存
💻 PAS
📖 第 1 页 / 共 3 页
字号:

{********************************************************************}
{                                                                    }
{       Developer Express Visual Component Library                   }
{       ExpressXPThemeManager                                        }
{                                                                    }
{       Copyright (c) 1998-2008 Developer Express Inc.               }
{       ALL RIGHTS RESERVED                                          }
{                                                                    }
{   The entire contents of this file is protected by U.S. and        }
{   International Copyright Laws. Unauthorized reproduction,         }
{   reverse-engineering, and distribution of all or any portion of   }
{   the code contained in this file is strictly prohibited and may   }
{   result in severe civil and criminal penalties and will be        }
{   prosecuted to the maximum extent possible under the law.         }
{                                                                    }
{   RESTRICTIONS                                                     }
{                                                                    }
{   THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES            }
{   (DCU, OBJ, DLL, ETC.) ARE CONFIDENTIAL AND PROPRIETARY TRADE     }
{   SECRETS OF DEVELOPER EXPRESS INC. THE REGISTERED DEVELOPER IS    }
{   LICENSED TO DISTRIBUTE THE EXPRESSXPTHEMEMANAGER AND ALL         }
{   ACCOMPANYING VCL CONTROLS AS PART OF AN EXECUTABLE PROGRAM ONLY. }
{                                                                    }
{   THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED       }
{   FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE         }
{   COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE        }
{   AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT   }
{   AND PERMISSION FROM DEVELOPER EXPRESS INC.                       }
{                                                                    }
{   CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON        }
{   ADDITIONAL RESTRICTIONS.                                         }
{                                                                    }
{********************************************************************}

unit dxUxTheme;

{$I cxVer.inc}

interface

uses
{$IFDEF DELPHI6}
  Types,
{$ENDIF}
  Windows, Classes, CommCtrl;

const
  dxMaxIntListCount = 10;

{$IFDEF CBUILDER11}
  {$EXTERNALSYM BPBF_COMPATIBLEBITMAP}
{$ENDIF}
  BPBF_COMPATIBLEBITMAP = 0; // Compatible bitmap
{$IFDEF CBUILDER11}
  {$EXTERNALSYM BPBF_DIB}
{$ENDIF}
  BPBF_DIB              = 1; // Device-independent bitmap
{$IFDEF CBUILDER11}
  {$EXTERNALSYM BPBF_TOPDOWNDIB}
{$ENDIF}
  BPBF_TOPDOWNDIB       = 2; // Top-down device-independent bitmap
{$IFDEF CBUILDER11}
  {$EXTERNALSYM BPBF_TOPDOWNMONODIB}
{$ENDIF}
  BPBF_TOPDOWNMONODIB   = 3; // Top-down monochrome device-independent bitmap
{$IFDEF CBUILDER11}
  {$EXTERNALSYM BPBF_COMPOSITED}
{$ENDIF}
  BPBF_COMPOSITED = BPBF_TOPDOWNDIB;

type
  TdxTheme = THandle;

  TdxThemeSize = Integer;

   TdxMargins = packed record
    cxLeftWidth: Integer;
    cxRightWidth: Integer;
    cyTopHeight: Integer;
    cyBottomHeight: Integer;
  end;

  PdxMargins = ^TdxMargins;

  TdxIntList = packed record
    iValueCount: Integer;
    iValues: array[0..dxMaxIntListCount - 1] of Integer;
  end;
  PdxIntList = ^TdxIntList;

  TdxPropertyOrigin = (PO_STATE, PO_PART, PO_CLASS, PO_GLOBAL, PO_NOTFOUND);

// vista extention
  TdxPaintBuffer = THandle;

  TdxDTTOpts = packed record
    dwSize: DWORD;
    dwFlags: DWORD;
    crText: COLORREF;
    crBorder: COLORREF;
    crShadow: COLORREF;
    iTextShadowType: Integer;
    ptShadowOffset: TPoint;
    iBorderSize: Integer;
    iFontPropId: Integer;
    iColorPropId: Integer;
    iStateId: Integer;
    fApplyOverlay: BOOL;
    iGlowSize: Integer;
    pfnDrawTextCallback: DWORD;
    lParam: LPARAM;
  end;
  PdxDTTOpts = ^TdxDTTOpts;

function OpenThemeData(hWnd: HWND; pszClassList: PWideChar): TdxTheme;
function CloseThemeData(hTheme: TdxTheme): HRESULT;

// functions for basic drawing support
function DrawThemeBackground(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  pRect: PRect; pClipRect: PRect = nil): HRESULT; overload;
function DrawThemeBackground(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  const pRect: TRect; pClipRect: PRect = nil): HRESULT; overload;
function DrawThemeBackground(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  const pRect: TRect; const pClipRect: TRect): HRESULT; overload;

function DrawThemeText(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  pszText: PWideChar; iCharCount: Integer; dwTextFlags, dwTextFlags2: DWORD;
  pRect: PRect): HRESULT; overload;
function DrawThemeText(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  pszText: string; iCharCount: Integer; dwTextFlags, dwTextFlags2: DWORD;
  const pRect: TRect): HRESULT; overload;

function DrawThemeTextEx(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  const pszText: WideString; iCharCount: Integer; dwTextFlags: DWORD;
  const pRect: TRect; const pOptions: TdxDTTOpts): HRESULT;

function GetThemeBackgroundContentRect(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  const BoundingRect: TRect; out ContentRect: TRect): HRESULT;

function GetThemeBackgroundExtent(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  pContentRect: PRect;
  out ExtentRect: TRect): HRESULT;

function GetThemePartSize(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  prc: PRect; eSize: TdxThemeSize; psz: PSize): HRESULT; overload;
function GetThemePartSize(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  const prc: TRect; eSize: TdxThemeSize; out psz: TSize): HRESULT; overload;
function GetThemePartSize(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  eSize: TdxThemeSize; out psz: TSize): HRESULT; overload;

function GetThemeTextExtent(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  pszTextL: PWideChar; iCharCount: Integer; dwTextFlags: DWORD;
  pBoundingRect: PRect; out ExtentRect: TRect): HRESULT;
function GetThemeTextMetrics(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  out tm: TEXTMETRIC): HRESULT;
function GetThemeBackgroundRegion(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  pRect: PRect; out Region: HRGN): HRESULT;
function HitTestThemeBackground(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  dwOptions: DWORD; pRect: PRect;
  hRgn: HRGN; ptTest: TPoint; out wHitTestCode: WORD): HRESULT;

function DrawThemeEdge(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  pDestRect: PRect; uEdge, uFlags: UINT; pContentRect: PRect): HRESULT; overload;
function DrawThemeEdge(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  const pDestRect: TRect; uEdge, uFlags: UINT; out pContentRect: TRect): HRESULT; overload;
function DrawThemeEdge(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  const pDestRect: TRect; uEdge, uFlags: UINT): HRESULT; overload;

function DrawThemeIcon(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
  pRect: PRect; himl: HIMAGELIST; iImageIndex: Integer): HRESULT;
function IsThemePartDefined(hTheme: TdxTheme; iPartId, iStateId: Integer): BOOL;
function IsThemeBackgroundPartiallyTransparent(hTheme: TdxTheme;
  iPartId, iStateId: Integer): BOOL;
function DrawThemeParentBackground(hWnd: HWND; DC: HDC; const prc: TRect): HRESULT;

// lower-level theme information services
function GetThemeColor(hTheme: TdxTheme; iPartId, iStateId, iPropId: Integer;
  out Color: TColorRef): HRESULT;
function GetThemeMetric(hTheme: TdxTheme; DC: HDC; iPartId, iStateId, iPropId: Integer;
  out iVal: Integer): HRESULT;
function GetThemeString(hTheme: TdxTheme; iPartId, iStateId, iPropId: Integer;
  pszBuff: PWideChar; cchMaxBuffChars: Integer): HRESULT;
function GetThemeBool(hTheme: TdxTheme; iPartId, iStateId, iPropId: Integer;
  out fVal{???}: BOOL): HRESULT; // TODO
function GetThemeInt(hTheme: TdxTheme; iPartId, iStateId, iPropId: Integer;
  out iVal: Integer): HRESULT;
function GetThemeEnumValue(hTheme: TdxTheme; iPartId, iStateId, iPropId: Integer;
  out iVal: Integer): HRESULT;
function GetThemePosition(hTheme: TdxTheme; iPartId, iStateId, iPropId: Integer;
  out Point: TPoint): HRESULT;
function GetThemeFont(hTheme: TdxTheme; DC: HDC; iPartId, iStateId, iPropId: Integer;
  out Font: LOGFONTW): HRESULT;
function GetThemeRect(hTheme: TdxTheme; iPartId, iStateId, iPropId: Integer;
  out Rect: TRect): HRESULT;
function GetThemeMargins(hTheme: TdxTheme; DC: HDC; iPartId, iStateId, iPropId: Integer;
  prc: PRect; out Margins: TdxMargins): HRESULT;
function GetThemeIntList(hTheme: TdxTheme; iPartId, iStateId, iPropId: Integer;
  out IntList: TdxIntList): HRESULT;
function GetThemePropertyOrigin(hTheme: TdxTheme; iPartId, iStateId, iPropId: Integer;
  out Origin: TdxPropertyOrigin): HRESULT;
function SetWindowTheme(hWnd: HWND; pszSubAppName, pszSubIdList:
  PWideChar): HRESULT;
function GetThemeFilename(hTheme: TdxTheme; iPartId, iStateId, iPropId: Integer;
  pszThemeFileName: PWideChar; cchMaxBuffChars: Integer): HRESULT;
function GetThemeSysColor(hTheme: TdxTheme; iColorId: Integer): COLORREF;
function GetThemeSysColorBrush(hTheme: TdxTheme; iColorId: Integer): HBRUSH;
function GetThemeSysBool(hTheme: TdxTheme; iBoolId: Integer): BOOL;
function GetThemeSysSize(hTheme: TdxTheme; iSizeId: Integer): Integer;
function GetThemeSysFont(hTheme: TdxTheme; iFontId: Integer; out lf: LOGFONTW): HRESULT;
function GetThemeSysString(hTheme: TdxTheme; iStringId: Integer; pszStringBuff:
  PWideChar; cchMaxStringChars: Integer): HRESULT;
function GetThemeSysInt(hTheme: TdxTheme; iIntId: Integer; var iValue: Integer): HRESULT; // TODO var -> out ???

function IsThemeActive: BOOL;
function IsAppThemed: BOOL;
function GetWindowTheme(hWnd: HWND): TdxTheme;
function EnableThemeDialogTexture(hWnd: HWND; dwFlags: DWORD): HRESULT;
function IsThemeDialogTextureEnabled(hWnd: HWND): BOOL;
function GetThemeAppProperties: DWORD;
procedure SetThemeAppProperties(dwFlags: DWORD);
function GetCurrentThemeName(pszThemeFileName: PWideChar;
  cchMaxNameChars: Integer; pszColorBuff: PWideChar;
  cchMaxColorChars: Integer; pszSizeBuff: PWideChar;
  cchMaxSizeChars: Integer): HRESULT;
function GetThemeDocumentationProperty(
  pszThemeName, pszPropertyName, pszValueBuff: PWideChar;
  cchMaxValChars: Integer): HRESULT;

//vista extention
type
  TdxBPPaintParams = packed record
    cbSize: DWORD;
    dwFlags: DWORD; // BPPF_ flags
    prcExclude: PRect;
    pBlendFunction: Pointer;
  end;
  PdxBPPaintParams = ^TdxBPPaintParams;

function BufferedPaintInit: HRESULT;
function BufferedPaintUnInit: HRESULT;
function BeginBufferedPaint(hdcTarget: HDC; prcTarget: PRect;
  dwFormat: DWORD; pPaintParams: PdxBPPaintParams; out dc: HDC): TdxPaintBuffer;
function EndBufferedPaint(hBufferedPaint: TdxPaintBuffer; fUpdateTarget: BOOL): HRESULT;
function BufferedPaintSetAlpha(hBufferedPaint: TdxPaintBuffer; prc: PRect; alpha: Byte): HRESULT;

function IsThemeLibraryLoaded: Boolean;
function IsWindowsXPOrLater: Boolean;

implementation

uses
  ComCtrls;

const
  ThemeLibraryName = 'UxTheme.dll';

type
  TCloseThemeData = function(hTheme: TdxTheme): HRESULT; stdcall;
  TDrawThemeBackground = function(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
    pRect: PRect; pClipRect: PRect = nil): HRESULT; stdcall;
  TDrawThemeEdge = function(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
    pDestRect: PRect; uEdge, uFlags: UINT; pContentRect: PRect): HRESULT; stdcall;
  TDrawThemeIcon = function(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
    pRect: PRect; himl: HIMAGELIST; iImageIndex: Integer): HRESULT; stdcall;
  TDrawThemeParentBackground = function(hWnd: HWND; DC: HDC; const prc: TRect): HRESULT; stdcall;
  TDrawThemeText = function(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
    pszText: PWideChar; iCharCount: Integer; dwTextFlags, dwTextFlags2: DWORD;
    pRect: PRect): HRESULT; stdcall;
  TDrawThemeTextEx = function(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
    const pszText: WideString; iCharCount: Integer; dwTextFlags: DWORD;
    pRect: PRect; const pOptions: TdxDTTOpts): HRESULT; stdcall;
  TEnableThemeDialogTexture = function(hWnd: HWND; dwFlags: DWORD): HRESULT; stdcall;
  TGetCurrentThemeName = function(pszThemeFileName: PWideChar; cchMaxNameChars: Integer;
    pszColorBuff: PWideChar; cchMaxColorChars: Integer; pszSizeBuff: PWideChar;
    cchMaxSizeChars: Integer): HRESULT; stdcall;
  TGetThemeAppProperties = function: DWORD; stdcall;
  TGetThemeBackgroundContentRect = function(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
    const BoundingRect: TRect; out ContentRect: TRect): HRESULT; stdcall;
  TGetThemeBackgroundRegion = function(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
    pRect: PRect; out Region: HRGN): HRESULT; stdcall;
  TGetThemeBackgroundExtent = function(hTheme: TdxTheme; DC: HDC; iPartId, iStateId: Integer;
    pContentRect: PRect; out ExtentRect: TRect): HRESULT; stdcall;
  TGetThemeBool = function(hTheme: TdxTheme; iPartId, iStateId, iPropId: Integer;
    out fVal: BOOL): HRESULT; stdcall;
  TGetThemeColor = function(hTheme: TdxTheme; iPartId, iStateId, iPropId: Integer;
    out Color: TColorRef): HRESULT; stdcall;
  TGetThemeDocumentationProperty = function(pszThemeName, pszPropertyName, pszValueBuff: PWideChar;
    cchMaxValChars: Integer): HRESULT; stdcall;
  TGetThemeEnumValue = function(hTheme: TdxTheme; iPartId, iStateId, iPropId: Integer;
    out iVal: Integer): HRESULT; stdcall;
  TGetThemeFilename = function(hTheme: TdxTheme; iPartId, iStateId, iPropId: Integer;
    pszThemeFileName: PWideChar; cchMaxBuffChars: Integer): HRESULT; stdcall;
  TGetThemeFont = function(hTheme: TdxTheme; DC: HDC; iPartId, iStateId, iPropId: Integer;
    out pFont: LOGFONTW): HRESULT; stdcall;
  TGetThemeInt = function(hTheme: TdxTheme; iPartId, iStateId, iPropId: Integer;
    out iVal: Integer): HRESULT; stdcall;
  TGetThemeIntList = function(hTheme: TdxTheme; iPartId, iStateId, iPropId: Integer;
    out IntList: TdxIntList): HRESULT; stdcall;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -