📄 dxoffice11.pas
字号:
dxOffice11ToolbarSelectedBrush := CreateSolidBrush(dxOffice11ToolbarSelectedColor);
dxOffice11DetachableSelectedBrush := dxOffice11ToolbarSelectedBrush;
dxOffice11StaticBorderBrush := dxOffice11DropDownBorderBrush1;
dxOffice11InPlaceSubItemBrush := CreateSolidBrush(dxOffice11InPlaceSubItemColor);
// TODO
dxOffice11SubMenuExpandBitmap := TBitmap.Create;
dxOffice11SubMenuExpandBitmap.Handle := LoadBitmap(HInstance, 'DXSUBMENUEXPAND');
PrepareSubMenuExpandBitmap(dxOffice11SubMenuExpandBitmap);
dxOffice11ExpandButtonBitmap1 := TBitmap.Create;
dxOffice11ExpandButtonBitmap1.Handle := LoadBitmap(HInstance, 'DXEXPANDBUTTON_MINUS');
dxOffice11ExpandButtonBitmap2 := TBitmap.Create;
dxOffice11ExpandButtonBitmap2.Handle := LoadBitmap(HInstance, 'DXEXPANDBUTTON_PLUS');
dxOffice11ExpandButtonColor1 := RGB(158, 174, 191);
dxOffice11ExpandButtonColor2 := RGB(46, 70, 95);
end;
procedure DestroyOffice11Brushes;
begin
dxOffice11SubMenuExpandBitmap.Free;
dxOffice11SubMenuExpandBitmap := nil;
dxOffice11ExpandButtonBitmap2.Free;
dxOffice11ExpandButtonBitmap2 := nil;
dxOffice11ExpandButtonBitmap1.Free;
dxOffice11ExpandButtonBitmap1 := nil;
if dxOffice11BarFingerBrush1 <> 0 then DeleteObject(dxOffice11BarFingerBrush1);
if dxOffice11BarFingerBrush2 <> 0 then DeleteObject(dxOffice11BarFingerBrush2);
if dxOffice11BarSeparatorBrush1 <> 0 then DeleteObject(dxOffice11BarSeparatorBrush1);
if dxOffice11BarSeparatorBrush2 <> 0 then DeleteObject(dxOffice11BarSeparatorBrush2);
if dxOffice11DropDownBorderBrush1 <> 0 then DeleteObject(dxOffice11DropDownBorderBrush1);
if dxOffice11MenuBrush <> 0 then DeleteObject(dxOffice11MenuBrush);
if dxOffice11SelectedBorderBrush <> 0 then DeleteObject(dxOffice11SelectedBorderBrush);
if dxOffice11OwnerControlDownedBrush <> 0 then DeleteObject(dxOffice11OwnerControlDownedBrush);
if dxOffice11DownedBrush <> 0 then DeleteObject(dxOffice11DownedBrush);
if dxOffice11DownedSelectedBrush <> 0 then DeleteObject(dxOffice11DownedSelectedBrush);
if dxOffice11DetachableBrush <> 0 then DeleteObject(dxOffice11DetachableBrush);
if dxOffice11ToolbarSelectedBrush <> 0 then DeleteObject(dxOffice11ToolbarSelectedBrush);
if dxOffice11InPlaceSubItemBrush <> 0 then DeleteObject(dxOffice11InPlaceSubItemBrush);
end;
function dxGetOffice11Scheme: TOffice11Scheme;
const
SZ_MAX_CHARS = 1024;
SStandardThemeFileName = 'LUNA.MSSTYLES';
SNormalColor = 'NORMALCOLOR';
SHomestead = 'HOMESTEAD';
SMetallic = 'METALLIC';
var
PThemeFileName, PThemeColor, PThemeSize: PWideChar;
S: string;
begin
Result := schUnknown;
if AreVisualStylesAvailable([]) then
begin
PThemeFileName := AllocMem(2 * SZ_MAX_CHARS);
PThemeColor := AllocMem(2 * SZ_MAX_CHARS);
PThemeSize := AllocMem(2 * SZ_MAX_CHARS);
try
if FAILED(GetCurrentThemeName(PThemeFileName, SZ_MAX_CHARS, PThemeColor,
SZ_MAX_CHARS, PThemeSize, SZ_MAX_CHARS)) then
Exit;
S := UpperCase(ExtractFileName(PThemeFileName));
// WindowsXP or above
if (S = SStandardThemeFileName) or (Win32MajorVersion > 5) then
begin
S := UpperCase(PThemeColor);
if S = SNormalColor then
Result := schNormalColor
else
if S = SHomestead then
Result := schHomestead
else
if S = SMetallic then
Result := schMetallic;
end;
finally
FreeMem(PThemeSize);
FreeMem(PThemeColor);
FreeMem(PThemeFileName);
end;
end;
end;
function GetdxOffice11NavPaneGroupCaptionColor(AStartColor: Boolean): TColor;
function TransformColorComponent(AValue: Byte): Byte;
begin
if AStartColor then
Result := AValue * 127 div 255 + 128
else
Result := AValue + (4 - AValue * 4 div 255);
end;
begin
Result := ColorToRGB(clBtnFace);
Result := RGB(TransformColorComponent(GetRValue(Result)),
TransformColorComponent(GetGValue(Result)), TransformColorComponent(GetBValue(Result)));
Result := GetRealColor(Result);
end;
procedure InitOffice11Colors;
const
Office11Colors: array[TOffice11SchemeColor, 0..48] of COLORREF = (
($FEECDD, $E2A981, $F5BE9E, $F9DAC3, $913500, $F1A675, $76C1FF, $D3F8FF, $98DDFF, $5295FE,
$9C613B, $E0A47B, $764127, $FFFFFF, $CB8C6A, $FFF9F1, $C9662A, $F9DBC4, $962D00, $F6F6F6,
$C2EEFF, $800000, $CCF4FF, $91D0FF, $8ED3FF, $4E91FE, $FCE1CB, $6FC0FF, $3E80FE, $F0C7A9,
$000000, $8D8D8D, $FBDABE, $94E6FB, $FADAC4, $962D00, $B96837, $962D00, $FBE5D3, $E4AE88,
$DCFFFF, $5BC0F7, $94E6FB, $1595EE, $087FE8, $7CDAF7, $D68759, $933803, $FFFFFF),
($DEF7F4, $91C6B7, $A7D9D9, $E4F0F2, $6B7760, $8CC2B0, $76C1FF, $D3F8FF, $98DDFF, $5295FE,
$588060, $8FC4B5, $335E51, $FFFFFF, $588060, $DEF7F4, $5E8674, $ADDEE1, $5E8D75, $EEF4F4,
$C2EEFF, $385D3F, $CCF4FF, $91D0FF, $8ED3FF, $4E91FE, $B6E3D8, $6FC0FF, $3E80FE, $9FD4C5,
$000000, $8D8D8D, $91BAAF, $94E6FB, $E4F1F2, $588060, $548973, $5E8D75, $DBF5F2, $97C9BC,
$DCFFFF, $5BC0F7, $94E6FB, $1595EE, $087FE8, $7CDAF7, $82C0AF, $447A63, $FFFFFF),
($FAF4F3, $B59799, $E5D7D7, $F7F3F3, $927476, $C8B2B3, $76C1FF, $D3F8FF, $98DDFF, $5295FE,
$947C7C, $B09193, $755454, $FFFFFF, $8F6D6E, $FFFFFF, $99797A, $E4DADB, $947C7C, $FFFAFD,
$C2EEFF, $6F4B4B, $CCF4FF, $91D0FF, $8ED3FF, $4E91FE, $E7D3D6, $6FC0FF, $3E80FE, $D3C0C0,
$000000, $8D8D8D, $EBE5E5, $94E6FB, $F7F3F3, $947C7C, $916F70, $947C7C, $F8F1F0, $BA9EA0,
$DCFFFF, $5BC0F7, $94E6FB, $1595EE, $087FE8, $7CDAF7, $BFA7A8, $916F70, $FFFFFF)
);
Office11GradientPercents: array[TOffice11SchemeColor] of Integer = (41, 125, 40);
var
I: Integer;
begin
FOffice11Scheme := dxGetOffice11Scheme;
FXPStandardScheme := AreVisualStylesAvailable([]) and (FOffice11Scheme <> schUnknown){luna};
if FXPStandardScheme then
begin
// bk colors
dxOffice11ToolbarsColor1 := Office11Colors[FOffice11Scheme, 0];
dxOffice11ToolbarsColor2 := Office11Colors[FOffice11Scheme, 1];
dxOffice11DockColor1 := Office11Colors[FOffice11Scheme, 2];
dxOffice11DockColor2 := Office11Colors[FOffice11Scheme, 3];
// bar: mark
dxOffice11BarMarkColors2[1] := Office11Colors[FOffice11Scheme, 4];
dxOffice11BarMarkColors1[1] := Office11Colors[FOffice11Scheme, 5];
dxOffice11BarMarkColors2[2] := Office11Colors[FOffice11Scheme, 6];
dxOffice11BarMarkColors1[2] := Office11Colors[FOffice11Scheme, 7];
dxOffice11BarMarkColors2[3] := Office11Colors[FOffice11Scheme, 8];
dxOffice11BarMarkColors1[3] := Office11Colors[FOffice11Scheme, 9];
// bar: border
dxOffice11BarBorderColors[1] := Office11Colors[FOffice11Scheme, 10];
dxOffice11BarBorderColors[2] := Office11Colors[FOffice11Scheme, 11];
// bar: border and mark (Normal, Selected, Downed)
for I := 1 to 3 do
dxOffice11BarBorderMarkColors[1, I] := GetMiddleRGB(dxOffice11BarMarkColors1[I], dxOffice11ToolbarsColor1, 90); // #6 ???
for I := 1 to 3 do
dxOffice11BarBorderMarkColors[2, I] := GetMiddleRGB(dxOffice11BarMarkColors2[I], dxOffice11BarBorderColors[2], 50); // #9
// bar: finger
dxOffice11BarFingerColor1 := Office11Colors[FOffice11Scheme, 12];
dxOffice11BarFingerColor2 := Office11Colors[FOffice11Scheme, 13];
// bar: separator
dxOffice11BarSeparatorColor1 := Office11Colors[FOffice11Scheme, 14];
dxOffice11BarSeparatorColor2 := Office11Colors[FOffice11Scheme, 15];
// bar: mark arrow
dxOffice11BarMarkArrowColor1 := ColorToRGB(clBlack);
dxOffice11BarMarkArrowColor2 := ColorToRGB(clWhite);
// bar: floating
dxOffice11BarFloatingBorderColor1 := Office11Colors[FOffice11Scheme, 16];
dxOffice11BarFloatingBorderColor2 := Office11Colors[FOffice11Scheme, 17];
dxOffice11BarFloatingCaptionTextColor1 := ColorToRGB(clWhite);
dxOffice11BarFloatingCaptionTextColor2 := ColorToRGB(clBlack);
dxOffice11BarFloatingCaptionTextColor3 := ColorToRGB(clBlack);
// drop downs, menus
dxOffice11DropDownBorderColor1 := Office11Colors[FOffice11Scheme, 18];
dxOffice11MenuColor := Office11Colors[FOffice11Scheme, 19];
// selected
dxOffice11ToolbarSelectedColor := Office11Colors[FOffice11Scheme, 20];
dxOffice11SelectedBorderColor := Office11Colors[FOffice11Scheme, 21];
dxOffice11SelectedColor1 := Office11Colors[FOffice11Scheme, 22];
dxOffice11SelectedColor2 := Office11Colors[FOffice11Scheme, 23];
dxOffice11SelectedDownColor1 := Office11Colors[FOffice11Scheme, 24];
dxOffice11SelectedDownColor2 := Office11Colors[FOffice11Scheme, 25];
dxOffice11OwnerControlDownedColor := Office11Colors[FOffice11Scheme, 26];
dxOffice11DownedColor := Office11Colors[FOffice11Scheme, 27];
dxOffice11DownedSelectedColor := Office11Colors[FOffice11Scheme, 28];
// detachable
dxOffice11DetachableColor := Office11Colors[FOffice11Scheme, 29];
// text
dxOffice11TextEnabledColor := Office11Colors[FOffice11Scheme, 30];
dxOffice11TextDisabledColor := Office11Colors[FOffice11Scheme, 31];
// Gradient Tube Percent
GradientPercent := Office11GradientPercents[FOffice11Scheme];
// LF
dxOffice11GroupColor := Office11Colors[FOffice11Scheme, 32];
// Outlook day navigator
dxOffice11DayNavigatorSelectedColor := Office11Colors[FOffice11Scheme, 33];
dxOffice11OutlookControlColor := Office11Colors[FOffice11Scheme, 34];
dxOffice11OutlookBorderColor := Office11Colors[FOffice11Scheme, 35];
// Office11 group row style colors
dxOffice11GroupIndentColor := $C9EEFD;
dxOffice11GroupRowSeparatorColor := dxOffice11BarBorderColors[2];
dxOffice11GroupRowTextColor := Office11Colors[FOffice11Scheme, 36];
// NavPane
dxOffice11NavPaneBorder := Office11Colors[FOffice11Scheme, 37];
dxOffice11NavPaneGroupCaptionColor1 := Office11Colors[FOffice11Scheme, 38];
dxOffice11NavPaneGroupCaptionColor2 := Office11Colors[FOffice11Scheme, 39];
dxOffice11NavPaneGroupCaptionHotColor1 := Office11Colors[FOffice11Scheme, 40];
dxOffice11NavPaneGroupCaptionHotColor2 := Office11Colors[FOffice11Scheme, 41];
dxOffice11NavPaneGroupCaptionPressedColor1 := Office11Colors[FOffice11Scheme, 42];
dxOffice11NavPaneGroupCaptionPressedColor2 := Office11Colors[FOffice11Scheme, 43];
dxOffice11NavPaneGroupCaptionPressedHotColor1 := Office11Colors[FOffice11Scheme, 44];
dxOffice11NavPaneGroupCaptionPressedHotColor2 := Office11Colors[FOffice11Scheme, 45];
dxOffice11NavPaneHeaderColor1 := Office11Colors[FOffice11Scheme, 46];
dxOffice11NavPaneHeaderColor2 := Office11Colors[FOffice11Scheme, 47];
dxOffice11NavPaneHeaderFontColor := Office11Colors[FOffice11Scheme, 48];
dxOffice11NavPaneSplitterColor1 := dxOffice11NavPaneHeaderColor1;
dxOffice11NavPaneSplitterColor2 := dxOffice11NavPaneHeaderColor2;
end
else
begin
// bk colors
dxOffice11DockColor1 := ColorToRGB(clBtnFace);
dxOffice11DockColor2 := GetMiddleRGB(clBtnFace, clWindow, 20);
dxOffice11ToolbarsColor1 := GetMiddleRGB(clBtnFace, clWindow, 22);
dxOffice11ToolbarsColor2 := GetMiddleRGB(clBtnFace, clWindow, 96);
// bar: mark
dxOffice11BarMarkColors2[1] := ColorToRGB(clBtnShadow);
dxOffice11BarMarkColors1[1] := GetMiddleRGB(dxOffice11BarMarkColors2[1], clWindow, 74);
// TODO
dxOffice11BarMarkColors1[2] := GetRealColor(GetLightColor(-15, 29, 100--15-29)); // Selected
// dxOffice11BarMarkColors1[2] := FlatToolbarsSelColor;
dxOffice11BarMarkColors2[2] := dxOffice11BarMarkColors1[2];
dxOffice11BarMarkColors1[3] := GetRealColor(GetLightColor(42, 11, 100-42-11)); // Downed
dxOffice11BarMarkColors2[3] := dxOffice11BarMarkColors1[3];
// bar: border
dxOffice11BarBorderColors[1] := GetMiddleRGB(clBtnFace, clWindow, 85);
dxOffice11BarBorderColors[2] := ColorToRGB(clBtnFace);
// bar: border and mark (Normal, Selected, Downed)
for I := 1 to 3 do
dxOffice11BarBorderMarkColors[1, I] := GetMiddleRGB(dxOffice11BarMarkColors2[I], clWindow, 50); // #6
for I := 1 to 3 do
dxOffice11BarBorderMarkColors[2, I] := GetMiddleRGB(dxOffice11BarMarkColors2[I], dxOffice11BarBorderColors[2], 50); // #9
// bar: finger
dxOffice11BarFingerColor1 := GetMiddleRGB(clBtnShadow, clWindow, 76);
dxOffice11BarFingerColor2 := ColorToRGB(clWindow);
// bar: separator
dxOffice11BarSeparatorColor1 := GetMiddleRGB(clBtnShadow, clWindow, 70);
dxOffice11BarSeparatorColor2 := ColorToRGB(clWhite);
// bar: mark arrow
dxOffice11BarMarkArrowColor1 := ColorToRGB(clBtnText);
dxOffice11BarMarkArrowColor2 := ColorToRGB(clWindow);
// bar: floating
dxOffice11BarFloatingBorderColor1 := ColorToRGB(clBtnShadow);
dxOffice11BarFloatingBorderColor2 := dxOffice11ToolbarsColor2;
dxOffice11BarFloatingCaptionTextColor1 := ColorToRGB(clBtnHighlight);
dxOffice11BarFloatingCaptionTextColor2 := ColorToRGB(clBtnText);
dxOffice11BarFloatingCaptionTextColor3 := ColorToRGB(clBtnText);
// drop down
dxOffice11DropDownBorderColor1 := ColorToRGB(clBtnShadow); // ?
dxOffice11MenuColor := ColorToRGB(clWindow); // ?
// selected
dxOffice11ToolbarSelectedColor := GetRealColor(GetLightColor(-2, 30, 72)); // ?
dxOffice11SelectedBorderColor := ColorToRGB(clHighlight);
dxOffice11SelectedColor1 := dxOffice11ToolbarSelectedColor;
dxOffice11SelectedColor2 := dxOffice11ToolbarSelectedColor;
dxOffice11OwnerControlDownedColor := dxOffice11ToolbarsColor2;
dxOffice11DownedColor := GetLightColor(41, 11, 48); // ?
dxOffice11DownedSelectedColor := GetRealColor(GetLightColor(14, 44, 40)); // ?
dxOffice11SelectedDownColor1 := dxOffice11DownedSelectedColor;
dxOffice11SelectedDownColor2 := dxOffice11DownedSelectedColor;
// detachable
dxOffice11DetachableColor := dxOffice11OwnerControlDownedColor;
// text
dxOffice11TextEnabledColor := ColorToRGB(clBtnText);
dxOffice11TextDisabledColor := ColorToRGB(clGrayText);
// Gradient Tube Percent
GradientPercent := 75;
// LF
dxOffice11GroupColor := ColorToRGB(clBtnFace);
// Outlook day navigator
dxOffice11DayNavigatorSelectedColor := dxOffice11DownedColor;
dxOffice11OutlookControlColor := dxOffice11DockColor1;
dxOffice11OutlookBorderColor := dxOffice11DropDownBorderColor1;
// Office11 group row style colors
dxOffice11GroupIndentColor := ColorToRGB(clBtnFace);
dxOffice11GroupRowTextColor := ColorToRGB(clBtnShadow);
dxOffice11GroupRowSeparatorColor := ColorToRGB(clBtnShadow);
// NavPane
dxOffice11NavPaneBorder := GetRealColor(ColorToRGB(clBtnShadow));
dxOffice11NavPaneGroupCaptionColor1 := GetdxOffice11NavPaneGroupCaptionColor(True);
dxOffice11NavPaneGroupCaptionColor2 := GetdxOffice11NavPaneGroupCaptionColor(False);
dxOffice11NavPaneGroupCaptionHotColor1 := dxOffice11SelectedColor1;
dxOffice11NavPaneGroupCaptionHotColor2 := dxOffice11SelectedColor2;
dxOffice11NavPaneGroupCaptionPressedColor1 := dxOffice11DownedColor;
dxOffice11NavPaneGroupCaptionPressedColor2 := dxOffice11NavPaneGroupCaptionPressedColor1;
dxOffice11NavPaneGroupCaptionPressedHotColor1 := dxOffice11DownedSelectedColor;
dxOffice11NavPaneGroupCaptionPressedHotColor2 := dxOffice11NavPaneGroupCaptionPressedHotColor1;
dxOffice11NavPaneHeaderColor1 := dxOffice11NavPaneBorder;
dxOffice11NavPaneHeaderColor2 := dxOffice11NavPaneBorder;
dxOffice11NavPaneHeaderFontColor := ColorToRGB(clHighlightText);
dxOffice11NavPaneSplitterColor1 := GetRealColor(ColorToRGB(clBtnFace));
dxOffice11NavPaneSplitterColor2 := dxOffice11NavPaneBorder;
end;
// bar: floating
dxOffice11BarFloatingBorderColor3 := dxOffice11ToolbarsColor1;
dxOffice11BarFloatingCaptionColor := dxOffice11BarFloatingBorderColor1;
// drop downs, menus
dxOffice11DropDownBorderColor2 := dxOffice11MenuColor;
dxOffice11MenuDownedColor1 := dxOffice11ToolbarsColor1;
dxOffice11MenuDownedColor2 := dxOffice11ToolbarsColor2;
dxOffice11MenuIndentColor1 := dxOffice11ToolbarsColor1;
dxOffice11MenuIndentColor2 := dxOffice11ToolbarsColor2;
dxOffice11MenuNonRecentIndentColor1 := GetMiddleRGB(dxOffice11MenuIndentColor1, clBlack, 92);
dxOffice11MenuNonRecentIndentColor2 := GetMiddleRGB(dxOffice11MenuIndentColor2, clBlack, 92);
// selected
dxOffice11DetachableSelectedColor := dxOffice11ToolbarSelectedColor;
// static
dxOffice11StaticBorderColor := dxOffice11DropDownBorderColor1;
// date
dxOffice11DateHeaderColor := dxOffice11DockColor1;
// inplace sub item
dxOffice11InPlaceSubItemColor := dxOffice11BarBorderMarkColors[2, 1];
dxOffice11InPlaceSubItemTextColor := dxOffice11BarFloatingCaptionTextColor1;
// LF painters
dxOffice11ControlBorderColor := dxOffice11DropDownBorderColor1;
end;
procedure CreateOffice11Colors;
begin
if FCounter = 0 then
begin
InitOffice11Colors;
CreateOffice11Brushes;
end;
Inc(FCounter);
end;
procedure RefreshOffice11Colors;
begin
InitOffice11Colors;
if FCounter <> 0 then
begin
DestroyOffice11Brushes;
CreateOffice11Brushes;
end;
end;
procedure ReleaseOffice11Colors;
begin
Dec(FCounter);
if FCounter = 0 then
DestroyOffice11Brushes;
end;
function IsHighContrastBlack: Boolean;
begin
Result := GetSysColor(COLOR_BTNFACE) = 0; // Black
end;
function IsHighContrastWhite: Boolean;
begin
Result := (GetSysColor(COLOR_BTNFACE) = $FFFFFF); // White
end;
function IsHighContrast2: Boolean;
begin
Result := (GetSysColor(COLOR_BTNFACE) = 0) and (GetSysColor(COLOR_BTNTEXT) <> $FFFFFF); // #2
end;
function IsXPStandardScheme: Boolean;
begin
Result := FXPStandardScheme;
end;
procedure FillGradientRect(DC: HDC; const ARect: TRect; AColor1, AColor2: TColor;
AHorizontal: Boolean);
procedure SoftwareGradientFill(ARGBColor1, ARGBColor2: DWORD);
var
FromR, ToR, FromG, ToG, FromB, ToB: Byte;
SR: TRect;
W, I, N: Integer;
R, G, B: Byte;
begin
FromR := GetRValue(ARGBColor1);
FromG := GetGValue(ARGBColor1);
FromB := GetBValue(ARGBColor1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -