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

📄 dxoffice11.pas

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

{*******************************************************************}
{                                                                   }
{       Developer Express Visual Component Library                  }
{       Office 11 routines                                          }
{                                                                   }
{       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 EXPRESSTHEME 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 dxOffice11;

{$I cxVer.inc}

interface

uses
  SysUtils, TypInfo, Windows, Messages, Graphics, Controls, Forms, Classes;

type
  TOffice11Scheme = (schUnknown, schNormalColor, schHomestead, schMetallic);
  TOffice11SchemeColor = schNormalColor .. schMetallic;

var
  { Colors }
  
  // dock
  dxOffice11DockColor1: COLORREF;
  dxOffice11DockColor2: COLORREF;
  // bar: background
  dxOffice11ToolbarsColor1: COLORREF;
  dxOffice11ToolbarsColor2: COLORREF;
  // bar: marks
  dxOffice11BarMarkColors1: array[1..3] of COLORREF; // Normal, Selected, Pressed
  dxOffice11BarMarkColors2: array[1..3] of COLORREF; // Normal, Selected, Pressed
  dxOffice11BarBorderColors: array[1..2] of COLORREF; // fixed colors
  dxOffice11BarBorderMarkColors: array[1..2, 1..3] of COLORREF;
  // bar: fingers, separators, mark arrows
  dxOffice11BarFingerColor1: COLORREF;
  dxOffice11BarFingerColor2: COLORREF;
  dxOffice11BarSeparatorColor1: COLORREF;
  dxOffice11BarSeparatorColor2: COLORREF;
  dxOffice11BarMarkArrowColor1: COLORREF;
  dxOffice11BarMarkArrowColor2: COLORREF;
  // bar: floating toolbar
  dxOffice11BarFloatingBorderColor1: COLORREF;
  dxOffice11BarFloatingBorderColor2: COLORREF;
  dxOffice11BarFloatingBorderColor3: COLORREF;
  dxOffice11BarFloatingCaptionColor: COLORREF;
  dxOffice11BarFloatingCaptionTextColor1: COLORREF;
  dxOffice11BarFloatingCaptionTextColor2: COLORREF;
  dxOffice11BarFloatingCaptionTextColor3: COLORREF;
  // drop downs
  dxOffice11MenuColor: COLORREF;
  dxOffice11MenuDownedColor1: COLORREF;
  dxOffice11MenuDownedColor2: COLORREF;
  dxOffice11MenuIndentColor1: COLORREF;
  dxOffice11MenuIndentColor2: COLORREF;
  dxOffice11MenuNonRecentIndentColor1: COLORREF;
  dxOffice11MenuNonRecentIndentColor2: COLORREF;
  dxOffice11DropDownBorderColor1: COLORREF;
  dxOffice11DropDownBorderColor2: COLORREF;
  // selected, pressed, downed
  dxOffice11ToolbarSelectedColor: COLORREF;
  dxOffice11SelectedBorderColor: COLORREF;
  dxOffice11SelectedColor1: COLORREF;
  dxOffice11SelectedColor2: COLORREF;
  dxOffice11SelectedDownColor1: COLORREF;
  dxOffice11SelectedDownColor2: COLORREF;
  dxOffice11OwnerControlDownedColor: COLORREF;
  dxOffice11DownedColor: COLORREF;
  dxOffice11DownedSelectedColor: COLORREF;
  // detachable
  dxOffice11DetachableColor: COLORREF;
  dxOffice11DetachableSelectedColor: COLORREF;
  // text
  dxOffice11TextEnabledColor: COLORREF;
  dxOffice11TextDisabledColor: COLORREF;
  // static
  dxOffice11StaticBorderColor: COLORREF;
  // date
  dxOffice11DateHeaderColor: COLORREF;
  // inplace sub item
  dxOffice11InPlaceSubItemColor: COLORREF;
  dxOffice11InPlaceSubItemTextColor: COLORREF;
  // LF painters
  // control border color
  dxOffice11ControlBorderColor: COLORREF;
  dxOffice11GroupColor: COLORREF;
  // Outlook colors
  dxOffice11DayNavigatorSelectedColor: COLORREF;
  dxOffice11OutlookBorderColor: COLORREF;
  dxOffice11OutlookControlColor: COLORREF;
  // Office11 group row style colors
  dxOffice11GroupIndentColor: COLORREF;
  dxOffice11GroupRowTextColor: COLORREF;
  dxOffice11GroupRowSeparatorColor: COLORREF;
  // NavPane colors
  dxOffice11NavPaneBorder: COLORREF;
  dxOffice11NavPaneGroupCaptionColor1: COLORREF;
  dxOffice11NavPaneGroupCaptionColor2: COLORREF;
  dxOffice11NavPaneGroupCaptionHotColor1: COLORREF;
  dxOffice11NavPaneGroupCaptionHotColor2: COLORREF;
  dxOffice11NavPaneGroupCaptionPressedColor1: COLORREF;
  dxOffice11NavPaneGroupCaptionPressedColor2: COLORREF;
  dxOffice11NavPaneGroupCaptionPressedHotColor1: COLORREF;
  dxOffice11NavPaneGroupCaptionPressedHotColor2: COLORREF;
  dxOffice11NavPaneHeaderColor1: COLORREF;
  dxOffice11NavPaneHeaderColor2: COLORREF;                 
  dxOffice11NavPaneHeaderFontColor: COLORREF;
  dxOffice11NavPaneSplitterColor1: COLORREF;
  dxOffice11NavPaneSplitterColor2: COLORREF;
  // Expand button colors
  dxOffice11ExpandButtonColor1: COLORREF;
  dxOffice11ExpandButtonColor2: COLORREF;

  { Brushes }

  dxOffice11BarFingerBrush1: HBRUSH;
  dxOffice11BarFingerBrush2: HBRUSH;
  dxOffice11BarSeparatorBrush1: HBRUSH;
  dxOffice11BarSeparatorBrush2: HBRUSH;
  dxOffice11MenuBrush: HBRUSH;
  dxOffice11SelectedBorderBrush: HBRUSH;
  dxOffice11ToolbarSelectedBrush: HBRUSH;
  dxOffice11OwnerControlDownedBrush: HBRUSH;
  dxOffice11DownedBrush: HBRUSH;
  dxOffice11DownedSelectedBrush: HBRUSH;

  dxOffice11DropDownBorderBrush1: HBRUSH;
  dxOffice11DropDownBorderBrush2: HBRUSH;
  dxOffice11DetachableBrush: HBRUSH;
  dxOffice11DetachableSelectedBrush: HBRUSH;

  dxOffice11StaticBorderBrush: HBRUSH;
  dxOffice11InPlaceSubItemBrush: HBRUSH;

  { Bitmaps }

  dxOffice11SubMenuExpandBitmap: TBitmap;
  dxOffice11ExpandButtonBitmap1: TBitmap;
  dxOffice11ExpandButtonBitmap2: TBitmap;

function GetOffice11Scheme: TOffice11Scheme;

function Dark(Col: TColor; Percentage: Byte): TColor;
function GetLightColor(ABtnFaceColorPart, AHighlightColorPart, AWindowColorPart: Integer): COLORREF;
function GetMiddleRGB(AColor1, AColor2: TColor; APercent: Integer): COLORREF;
function GetRealColor(AColor: COLORREF): COLORREF;
function Light(Col: TColor; Percentage: Byte): TColor;

procedure CreateOffice11Colors;
procedure RefreshOffice11Colors;
procedure ReleaseOffice11Colors;

function IsHighContrastBlack: Boolean;
function IsHighContrastWhite: Boolean;
function IsHighContrast2: Boolean;
function IsXPStandardScheme: Boolean;
procedure FillGradientRect(DC: HDC; const ARect: TRect; AColor1, AColor2: TColor;
  AHorizontal: Boolean);
procedure FillTubeGradientRect(DC: HDC; const ARect: TRect; AColor1, AColor2: TColor;
  AHorizontal: Boolean);
procedure FillRectByColor(DC: HDC; const R: TRect; AColor: TColor);
procedure FrameRectByColor(DC: HDC; const R: TRect; AColor: TColor);
function GetGradientColorRect(const ARect: TRect; X: Integer; AColor1, AColor2: TColor;
  AHorizontal: Boolean): TColorRef;
procedure Office11FrameSelectedRect(DC: HDC; const R: TRect);
procedure Office11DrawFingerElements(DC: HDC; ARect: TRect; AHorizontal: Boolean;
  ABrush1: HBRUSH = 0; ABrush2: HBRUSH = 0);
procedure Office11DrawItemArrow(DC: HDC; R: TRect; ADownArrow: Boolean;
  Enabled, Selected, Flat: Boolean);
procedure Office11DrawLargeItemArrow(DC: HDC; R: TRect; ADownArrow: Boolean;
  Size: Integer; Selected, Enabled, Flat: Boolean);
procedure Office11DrawSizeGrip(DC: HDC; ARect: TRect;
  AColor1: TColor = clDefault; AColor2: TColor = clDefault);

implementation

{$R dxOffice11.res}

uses
  dxThemeManager, dxUxTheme, dxThemeConsts;

type
  TTriVertex = packed record
    X: Integer;
    Y: Integer;
    Red: WORD;
    Green: WORD;
    Blue: WORD;
    Alpha: WORD;
  end;

var
  FCounter: Integer;
  FOffice11Scheme: TOffice11Scheme;
  FXPStandardScheme: Boolean;
  GradientPercent: Integer;

  FMsimg32Library: HMODULE;
  GradientFill: function (ADC: THandle;
    const AVertex: TTriVertex; ANumVertex: Integer;
    const AMesh: TGradientRect; ANumMesh: Integer; AMode: DWORD): Boolean; stdcall;

function GetOffice11Scheme: TOffice11Scheme;
begin
  Result := FOffice11Scheme;
end;

function Dark(Col: TColor; Percentage: Byte): TColor;
var
  R, G, B: Byte;
begin
  Col := ColorToRGB(Col);
  R := GetRValue(Col); G := GetGValue(Col); B := GetBValue(Col);
  R := Trunc(R * Percentage / 100);
  G := Trunc(G * Percentage / 100);
  B := Trunc(B * Percentage / 100);
  Result := RGB(R, G, B);
end;

function GetLightColor(ABtnFaceColorPart, AHighlightColorPart, AWindowColorPart: Integer): COLORREF;
var
  ABtnFaceColor, AHighlightColor, AWindowColor: COLORREF;

  function GetLightIndex(ABtnFaceValue, AHighlightValue, AWindowValue: Byte): Integer;
  begin
    Result :=
      MulDiv(ABtnFaceValue, ABtnFaceColorPart, 100) +
      MulDiv(AHighlightValue, AHighlightColorPart, 100) +
      MulDiv(AWindowValue, AWindowColorPart, 100);
    if Result < 0 then Result := 0;
    if Result > 255 then Result := 255;
  end;

begin
  ABtnFaceColor := GetSysColor(COLOR_BTNFACE);
  AHighlightColor := GetSysColor(COLOR_HIGHLIGHT);
  AWindowColor := GetSysColor(COLOR_WINDOW);
  if (ABtnFaceColor = 0) or (ABtnFaceColor = $FFFFFF) then
    Result := AHighlightColor
  else
    Result := RGB(
      GetLightIndex(GetRValue(ABtnFaceColor), GetRValue(AHighlightColor), GetRValue(AWindowColor)),
      GetLightIndex(GetGValue(ABtnFaceColor), GetGValue(AHighlightColor), GetGValue(AWindowColor)),
      GetLightIndex(GetBValue(ABtnFaceColor), GetBValue(AHighlightColor), GetBValue(AWindowColor)));
end;

function GetMiddleRGB(AColor1, AColor2: TColor; APercent: Integer): COLORREF;

  function CalcValue(Value1, Value2: Byte): Byte;
  var
    I: Integer;
  begin
    I := MulDiv(Value1, APercent, 100) + MulDiv(Value2, 100 - APercent, 100);
    if I > 255 then I := 255;
    Result := I;
  end;

begin
  AColor1 := ColorToRGB(AColor1);
  AColor2 := ColorToRGB(AColor2);
  Result := RGB(
    CalcValue(GetRValue(AColor1), GetRValue(AColor2)),
    CalcValue(GetGValue(AColor1), GetGValue(AColor2)),
    CalcValue(GetBValue(AColor1), GetBValue(AColor2)));
  Result := GetRealColor(Result);
end;

function GetRealColor(AColor: COLORREF): COLORREF;
var
  DC: HDC;
begin
  DC := GetDC(0);
  Result := GetNearestColor(DC, AColor);
  ReleaseDC(0, DC);
end;

function Light(Col: TColor; Percentage: Byte): TColor;
var
  R, G, B: Byte;
begin
  Col := ColorToRGB(Col);
  R := GetRValue(Col); G := GetGValue(Col); B := GetBValue(Col);
  R := Trunc(255 - Percentage / 100 * (255 - R));
  G := Trunc(255 - Percentage / 100 * (255 - G));
  B := Trunc(255 - Percentage / 100 * (255 - B));
  Result := RGB(R, G, B);
end;

procedure PrepareSubMenuExpandBitmap(ABitmap: TBitmap);
var
  I, J: Integer;
  ATransparentColor, AColor1, AColor2, APixelColor: COLORREF;
  AMinValue, AMaxValue, AValue: Byte;
begin
  ATransparentColor := ABitmap.Canvas.Pixels[0, 0];
//  AColor := ColorToRGB(clWindow);
  AColor1 := dxOffice11ToolbarsColor1;
  AColor2 := dxOffice11ToolbarsColor2;
  if AColor1 = AColor2 then
  begin
    if AColor1 = 0 then
      AColor2 := $FFFFFF
    else
      AColor2 := 0;
  end;
  AMaxValue := 1;
  AMinValue := 255;
  for I := 0 to ABitmap.Width - 1 do
    for J := 0 to ABitmap.Height - 1 do
    begin
      APixelColor := ABitmap.Canvas.Pixels[I, J];
      if (APixelColor <> ATransparentColor) and (APixelColor <> 0{mark}) then
      begin
        AValue := GetRValue(APixelColor);
        if AValue > AMaxValue then
          AMaxValue := AValue;
        if AValue < AMinValue then
          AMinValue := AValue;
      end;
    end;
  for I := 0 to ABitmap.Width - 1 do
    for J := 0 to ABitmap.Height - 1 do
    begin
      APixelColor := ABitmap.Canvas.Pixels[I, J];
      if (APixelColor <> ATransparentColor) and (APixelColor <> 0{mark}) then
      begin
//        APixelColor := GetMiddleRGB(APixelColor, AColor, 50);
        AValue := GetRValue(APixelColor);
        APixelColor := GetMiddleRGB(AColor1, AColor2, MulDiv(AValue - AMinValue, 100, AMaxValue - AMinValue));
        ABitmap.Canvas.Pixels[I, J] := APixelColor;
      end;  
    end;
end;

procedure CreateOffice11Brushes;
begin
  dxOffice11BarFingerBrush1 := CreateSolidBrush(dxOffice11BarFingerColor1);
  dxOffice11BarFingerBrush2 := CreateSolidBrush(dxOffice11BarFingerColor2);
  dxOffice11BarSeparatorBrush1 := CreateSolidBrush(dxOffice11BarSeparatorColor1);
  dxOffice11BarSeparatorBrush2 := CreateSolidBrush(dxOffice11BarSeparatorColor2);
  dxOffice11DropDownBorderBrush1 := CreateSolidBrush(dxOffice11DropDownBorderColor1);
  dxOffice11MenuBrush := CreateSolidBrush(dxOffice11MenuColor);
  dxOffice11DropDownBorderBrush2 := dxOffice11MenuBrush;
  dxOffice11SelectedBorderBrush := CreateSolidBrush(dxOffice11SelectedBorderColor);
  dxOffice11OwnerControlDownedBrush := CreateSolidBrush(dxOffice11OwnerControlDownedColor);
  dxOffice11DownedBrush := CreateSolidBrush(dxOffice11DownedColor);
  dxOffice11DownedSelectedBrush := CreateSolidBrush(dxOffice11DownedSelectedColor);
  dxOffice11DetachableBrush := CreateSolidBrush(dxOffice11DetachableColor);

⌨️ 快捷键说明

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