Skip to content

Commit ae92074

Browse files
committed
DIC - Improved support for TBitBtn
DIC - Added hook for TLogColors DIC - Fixed bug on UxTheme Hooks DIC - Fixed bug on unload wizard (Restored Controls Colors)
1 parent 0fffc47 commit ae92074

18 files changed

+390
-116
lines changed

delphi-ide-theme-editor/IDE PlugIn/Colorizer.Hooks.GDIPOBJ.pas

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ interface
3030
implementation
3131

3232
uses
33+
Vcl.Styles,
34+
Vcl.Themes,
3335
Colorizer.Utils,
36+
Colorizer.Vcl.Styles,
37+
System.Types,
3438
JclDebug,
3539
DDetours,
3640
Graphics,
@@ -89,13 +93,28 @@ implementation
8993
Trampoline_TGPGraphics_DrawPath : function (Self : TGPGraphics; pen: TGPPen; path: TGPGraphicsPath): TStatus = nil;
9094
Trampoline_TGPGraphics_FillPath : function (Self : TGPGraphics; brush: TGPBrush; path: TGPGraphicsPath): TStatus = nil;
9195

96+
function MakeTRect(const Rect: TGPRectF): TRect;
97+
begin
98+
Result.Left := Trunc(rect.X);
99+
Result.Top := Trunc(Rect.Y);
100+
Result.Width := Trunc(Rect.Width);
101+
Result.Height:= Trunc(Rect.Height);
102+
end;
103+
104+
92105
function Detour_TGPGraphics_DrawPath(Self : TGPGraphics; pen: TGPPen; path: TGPGraphicsPath): TStatus;
93106
const
94107
sTGradientTabSet= 'GDIPlus.GradientTabs.TGradientTabSet.DrawTabsToMemoryBitmap';
95108
var
96109
sCaller : string;
97110
PenColor, LGPColor: TGPColor;
111+
// Hooked : BooleaN;
112+
// bounds: TGPRectF;
113+
// LRect : TRect;
114+
// LDetails: TThemedElementDetails;
98115
begin
116+
// AddLog2('Detour_TGPGraphics_DrawPath ');
117+
// Hooked:=False;
99118
//AddLog2('Detour_TGPGraphics_DrawPath', '1');
100119
if Assigned(TColorizerLocalSettings.Settings) and TColorizerLocalSettings.Settings.Enabled and (pen<>nil) then
101120
begin
@@ -108,11 +127,25 @@ function Detour_TGPGraphics_DrawPath(Self : TGPGraphics; pen: TGPPen; path: TGPG
108127
sCaller := ProcByLevel(3);
109128
//AddLog2('Detour_TGPGraphics_DrawPath sCaller', sCaller);
110129
if SameText(sTGradientTabSet, sCaller) then
130+
begin
131+
//Hooked:=True;
111132
pen.SetColor(LGPColor);
133+
end;
112134
end;
113135
end;
114136

115-
Result:=Trampoline_TGPGraphics_DrawPath(Self, pen, path);
137+
// if 1=1 then
138+
// begin
139+
// AddLog2('Detour_TGPGraphics_DrawPath Hooked');
140+
// path.GetBounds(bounds);
141+
// MakeTRect(bounds);
142+
//
143+
// LDetails := StyleServices.GetElementDetails(ttTabItemNormal);
144+
// ColorizerStyleServices.DrawParentBackground(Self.FromHDC , Self.GetHDC, LDetails, False);
145+
// result:=TStatus.Ok;
146+
// end
147+
// else
148+
Result:=Trampoline_TGPGraphics_DrawPath(Self, pen, path);
116149
//AddLog('Detour_TGPGraphics_DrawPath', '2');
117150
end;
118151

delphi-ide-theme-editor/IDE PlugIn/Colorizer.Hooks.IDE.pas

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ interface
5454
{$IFDEF DELPHIXE8} sCoreIDEModule = 'coreide220.bpl';{$ENDIF}
5555

5656
{$IFDEF DELPHIXE6} sModernThemeModule = 'ModernTheme200.bpl';{$ENDIF}
57+
5758
{$IFDEF DELPHIXE7} sModernThemeModule = 'ModernTheme210.bpl';{$ENDIF}
5859
{$IFDEF DELPHIXE7} sdesignideModule = 'designide210.bpl';{$ENDIF}
5960

@@ -88,6 +89,8 @@ implementation
8889
GraphUtil,
8990
SysUtils,
9091
CaptionedDockTree,
92+
uRttiHelper,
93+
ToolsAPI,
9194
Graphics;
9295

9396
type
@@ -157,6 +160,47 @@ TDockCaptionDrawerClass = class(TDockCaptionDrawer);
157160
Rect: TRect; State: TOwnerDrawState) of object;
158161
159162
}
163+
164+
165+
{
166+
0035C454 13161 1DEA Debugmgropts::TLogColors::
167+
00360384 13091 1DEB __fastcall Debugmgropts::TLogColors::TLogColors()
168+
0036088C 13090 1DEC __fastcall Debugmgropts::TLogColors::~TLogColors()
169+
0036034C 13092 1DED __fastcall Debugmgropts::TLogColors::Assign(Debugmgropts::TLogColors *)
170+
003608CC 13089 1DEE __fastcall Debugmgropts::TLogColors::GetColor(Toolsapi::TLogItemType)
171+
}
172+
173+
Trampoline_coreide_TLogColors_GetColor : function(Self: TObject; Index: TLogItemType): TObject;
174+
175+
176+
function Detour_coreide_TLogColors_GetColor(Self: TObject; Index: TLogItemType): TObject;
177+
begin
178+
//AddLog2('Detour_coreide_TLogColors_GetColor');
179+
// property ForegroundColor: TColor;
180+
// property BackgroundColor: TColor;
181+
182+
Result:=Trampoline_coreide_TLogColors_GetColor(Self, Index);
183+
if (Result<>nil) and Assigned(TColorizerLocalSettings.Settings) and TColorizerLocalSettings.Settings.Enabled and Assigned(TColorizerLocalSettings.ColorMap) then
184+
begin
185+
case Index of
186+
litLogBreakEval,
187+
litBreakpointMessage,
188+
litSourceBreakpoint : begin
189+
TRttiUtils.SetRttiPropertyValue(Result, 'BackgroundColor', TColorizerLocalSettings.ColorMap.WindowColor);
190+
TRttiUtils.SetRttiPropertyValue(Result, 'ForegroundColor', TColorizerLocalSettings.ColorMap.HotFontColor);
191+
end;
192+
193+
else
194+
begin
195+
TRttiUtils.SetRttiPropertyValue(Result, 'BackgroundColor', TColorizerLocalSettings.ColorMap.WindowColor);
196+
TRttiUtils.SetRttiPropertyValue(Result, 'ForegroundColor', TColorizerLocalSettings.ColorMap.FontColor);
197+
end;
198+
end;
199+
200+
end;
201+
end;
202+
203+
160204
procedure CustomProjectTree2PaintText(Self : TObject; Sender: TObject{TBaseVirtualTree}; const TargetCanvas: TCanvas; Node: {PVirtualNode}Pointer; Column: Integer{TColumnIndex}; TextType: Byte {TVSTTextType});
161205
begin
162206
//TargetCanvas.Font.Color:=clRed;
@@ -1023,6 +1067,8 @@ procedure InstallHooksIDE;
10231067
CoreIDEModule := LoadLibrary(sCoreIDEModule);
10241068
if CoreIDEModule<>0 then
10251069
begin
1070+
Trampoline_coreide_TLogColors_GetColor:= InterceptCreate(sCoreIDEModule, '@Debugmgropts@TLogColors@GetColor$qqr21Toolsapi@TLogItemType', @Detour_coreide_TLogColors_GetColor);
1071+
10261072
Trampoline_CompilerMsgLine_Draw := InterceptCreate(sCoreIDEModule, sCompilerMsgLineDraw, @Detour_TCompilerMsgLine_Draw);
10271073
Trampoline_TitleLine_Draw := InterceptCreate(sCoreIDEModule, sTitleLineDraw, @Detour_TTitleLine_Draw);
10281074
Trampoline_TFileFindLine_Draw := InterceptCreate(sCoreIDEModule, sFileFindLineDraw, @Detour_TFileFindLine_Draw);
@@ -1088,6 +1134,9 @@ procedure InstallHooksIDE;
10881134
begin
10891135
//InterceptRemove(@TrampolineOpenKey);
10901136
//InterceptRemove(@TrampolineInternalLoadPropValues);
1137+
1138+
1139+
InterceptRemove(@Trampoline_coreide_TLogColors_GetColor);
10911140
InterceptRemove(@Trampoline_CompilerMsgLine_Draw);
10921141
InterceptRemove(@Trampoline_TitleLine_Draw);
10931142
InterceptRemove(@Trampoline_TFileFindLine_Draw);

delphi-ide-theme-editor/IDE PlugIn/Colorizer.Hooks.ThemedActnCtrls.pas

Lines changed: 18 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,11 @@ procedure Detour_TThemedMenuItem_DrawBackground(Self: TThemedMenuItemClass;var P
144144
if TColorizerLocalSettings.Settings.Enabled and TColorizerLocalSettings.Settings.UseVCLStyles and TColorizerLocalSettings.Settings.VCLStylesMenusColors then
145145
begin
146146
Self.PaintRectHelper := PaintRect;
147-
if ColorizerStyleServices.IsSystemStyle then
148-
ColorizerStyleServices.DrawElement(Self.Canvas.Handle, StyleServices.GetElementDetails(tmPopupBackground), Self.PaintRectHelper);
149-
ColorizerStyleServices.DrawElement(Self.Canvas.Handle, StyleServices.GetElementDetails(tmPopupGutter), Self.GutterRectHelper);
147+
// if ColorizerStyleServices.IsSystemStyle then
148+
// ColorizerStyleServices.DrawElement(Self.Canvas.Handle, StyleServices.GetElementDetails(tmPopupBackground), Self.PaintRectHelper);
149+
// ColorizerStyleServices.DrawElement(Self.Canvas.Handle, StyleServices.GetElementDetails(tmPopupGutter), Self.GutterRectHelper);
150+
// ColorizerStyleServices.DrawElement(Self.Canvas.Handle, ColorizerStyleServices.GetElementDetails(tmPopupBackground), Self.PaintRectHelper);
151+
ColorizerStyleServices.DrawElement(Self.Canvas.Handle, ColorizerStyleServices.GetElementDetails(tmPopupGutter), Self.GutterRectHelper);
150152
end
151153
else
152154
Trampoline_TThemedMenuItem_DrawBackground(Self, PaintRect);
@@ -257,7 +259,7 @@ procedure Detour_TThemedMenuItem_DoDrawText(Self: TThemedMenuItemClass;DC: HDC;
257259
else
258260
if not Self.Enabled then
259261
begin
260-
LBackColor:= ColorizerStyleServices.GetSystemColor(clBtnFace);
262+
LBackColor:= TColorizerLocalSettings.ColorMap.MenuColor;//ColorizerStyleServices.GetSystemColor(clBtnFace);
261263
Self.Canvas.Brush.Color := LBackColor;
262264
end;
263265

@@ -312,23 +314,6 @@ procedure Detour_TThemedPopupMenu_NCPaint(Self: TThemedPopupMenuClass; DC: HDC);
312314
Trampoline_TThemedPopupMenu_NCPaint(Self, DC);
313315
end;
314316

315-
//procedure Detour_TWinControl_CreateWnd(Self : TWinControl);
316-
//var
317-
// AStyle : NativeInt;
318-
//begin
319-
// Trampoline_TWinControl_CreateWnd(Self);
320-
// if TColorizerLocalSettings.Settings.Enabled then
321-
// begin
322-
// if (Self is TCustomActionPopupMenu) {or (Self is TThemedPopupMenu) or (Self is TXPStylePopupMenu)} then
323-
// begin
324-
// AStyle := GetWindowLong(Self.Handle, GWL_EXSTYLE);
325-
// if (AStyle and WS_EX_LAYERED) = 0 then
326-
// SetWindowLong(Self.Handle, GWL_EXSTYLE, AStyle or WS_EX_LAYERED);
327-
// SetLayeredWindowAttributes(Self.Handle, 0, 220, LWA_ALPHA);
328-
// end;
329-
// end;
330-
//end;
331-
332317
procedure Detour_TCustomActionPopupMenu_CMVisibleChanged(Self : TCustomActionPopupMenuClass;var Message: TMessage);
333318
var
334319
AStyle : NativeInt;
@@ -343,18 +328,6 @@ procedure Detour_TCustomActionPopupMenu_CMVisibleChanged(Self : TCustomActionPop
343328
Trampoline_TCustomActionPopupMenu_CMVisibleChanged(Self, Message);
344329
end;
345330

346-
//procedure Detour_TCustomActionPopupMenu_CreateParams(Self : TCustomActionPopupMenuClass; var Params: TCreateParams);
347-
//begin
348-
// if TColorizerLocalSettings.Settings.Enabled and TColorizerLocalSettings.Settings.UseVCLStyles and TColorizerLocalSettings.Settings.VCLStylesMenusColors then
349-
// begin
350-
// with Params do
351-
// if (ExStyle and WS_EX_LAYERED) = 0 then
352-
// ExStyle := ExStyle or WS_EX_LAYERED;
353-
// end;
354-
// Trampoline_TCustomActionPopupMenu_CreateParams(Self, Params);
355-
//end;
356-
357-
358331
procedure Detour_TCustomActionPopupMenu_DrawBackground(Self : TCustomActionPopupMenuClass);
359332
begin
360333
if TColorizerLocalSettings.Settings.Enabled and TColorizerLocalSettings.Settings.UseVCLStyles and TColorizerLocalSettings.Settings.VCLStylesMenusColors then
@@ -546,9 +519,7 @@ procedure InstallThemedActnCtrlsHooks;
546519
Trampoline_TThemedPopupMenu_NCPaint := InterceptCreate(@TThemedPopupMenuClass.NCPaint, @Detour_TThemedPopupMenu_NCPaint);
547520

548521
Trampoline_TCustomActionPopupMenu_DrawBackground := InterceptCreate(@TCustomActionPopupMenuClass.DrawBackground, @Detour_TCustomActionPopupMenu_DrawBackground);
549-
//Trampoline_TCustomActionPopupMenu_CreateParams := InterceptCreate(@TCustomActionPopupMenuClass.CreateParams, @Detour_TCustomActionPopupMenu_CreateParams);
550522
Trampoline_TCustomActionPopupMenu_CMVisibleChanged := InterceptCreate(@TCustomActionPopupMenuClass.CMVisibleChanged, @Detour_TCustomActionPopupMenu_CMVisibleChanged);
551-
//Trampoline_TWinControl_CreateWnd := InterceptCreate(@TWinControlClass.CreateWnd, @Detour_TWinControl_CreateWnd);
552523

553524
Trampoline_TThemedMenuButton_DoDrawText := InterceptCreate(TThemedMenuButton(nil).DoDrawTextAddress, @Detour_TThemedMenuButton_DoDrawText);
554525
Trampoline_TThemedMenuButton_DrawBackground := InterceptCreate(@TThemedMenuButtonClass.DrawBackground, @Detour_TThemedMenuButton_DrawBackground);
@@ -557,44 +528,18 @@ procedure InstallThemedActnCtrlsHooks;
557528

558529
procedure RemoveThemedActnCtrlsHooks;
559530
begin
560-
if Assigned(Trampoline_TThemedMenuItem_DrawBackground) then
561-
InterceptRemove(@Trampoline_TThemedMenuItem_DrawBackground);
562-
563-
if Assigned(Trampoline_TThemedMenuItem_DrawSeparator) then
564-
InterceptRemove(@Trampoline_TThemedMenuItem_DrawSeparator);
565-
566-
if Assigned(Trampoline_TThemedMenuItem_DrawSubMenuGlyph) then
567-
InterceptRemove(@Trampoline_TThemedMenuItem_DrawSubMenuGlyph);
568-
569-
if Assigned(Trampoline_TThemedMenuItem_DrawText) then
570-
InterceptRemove(@Trampoline_TThemedMenuItem_DrawText);
571-
572-
if Assigned(Trampoline_TThemedMenuItem_DoDrawText) then
573-
InterceptRemove(@Trampoline_TThemedMenuItem_DoDrawText);
574-
575-
if Assigned(Trampoline_TThemedMenuItem_DoDrawMenuCheck) then
576-
InterceptRemove(@Trampoline_TThemedMenuItem_DoDrawMenuCheck);
577-
578-
if Assigned(Trampoline_TThemedPopupMenu_NCPaint) then
579-
InterceptRemove(@Trampoline_TThemedPopupMenu_NCPaint);
580-
581-
if Assigned(Trampoline_TCustomActionPopupMenu_DrawBackground) then
582-
InterceptRemove(@Trampoline_TCustomActionPopupMenu_DrawBackground);
583-
584-
if Assigned(Trampoline_TCustomActionPopupMenu_CMVisibleChanged) then
585-
InterceptRemove(@Trampoline_TCustomActionPopupMenu_CMVisibleChanged);
586-
587-
// if Assigned(Trampoline_TWinControl_CreateWnd) then
588-
// InterceptRemove(@Trampoline_TWinControl_CreateWnd);
589-
590-
if Assigned(Trampoline_TThemedMenuButton_DoDrawText) then
591-
InterceptRemove(@Trampoline_TThemedMenuButton_DoDrawText);
592-
593-
if Assigned(Trampoline_TThemedMenuButton_DrawBackground) then
594-
InterceptRemove(@Trampoline_TThemedMenuButton_DrawBackground);
595-
596-
if Assigned(Trampoline_TXPStylePopupMenu_NCPaint) then
597-
InterceptRemove(@Trampoline_TXPStylePopupMenu_NCPaint);
531+
InterceptRemove(@Trampoline_TThemedMenuItem_DrawBackground);
532+
InterceptRemove(@Trampoline_TThemedMenuItem_DrawSeparator);
533+
InterceptRemove(@Trampoline_TThemedMenuItem_DrawSubMenuGlyph);
534+
InterceptRemove(@Trampoline_TThemedMenuItem_DrawText);
535+
InterceptRemove(@Trampoline_TThemedMenuItem_DoDrawText);
536+
InterceptRemove(@Trampoline_TThemedMenuItem_DoDrawMenuCheck);
537+
InterceptRemove(@Trampoline_TThemedPopupMenu_NCPaint);
538+
InterceptRemove(@Trampoline_TCustomActionPopupMenu_DrawBackground);
539+
InterceptRemove(@Trampoline_TCustomActionPopupMenu_CMVisibleChanged);
540+
InterceptRemove(@Trampoline_TThemedMenuButton_DoDrawText);
541+
InterceptRemove(@Trampoline_TThemedMenuButton_DrawBackground);
542+
InterceptRemove(@Trampoline_TXPStylePopupMenu_NCPaint);
598543
end;
599544

600545
end.

0 commit comments

Comments
 (0)