Skip to content

Commit bc5388a

Browse files
committed
TMemo running into error when applying styles in Python x64. Ref: Embarcadero/DelphiVCL4Python#18
1 parent 27503c0 commit bc5388a

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

Source/vcl/WrapVclThemes.pas

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,24 @@ TStyleManagerStyleNamesAccess = class(TContainerAccess)
8888
implementation
8989

9090
uses
91-
System.SysUtils, Vcl.Controls, MethodCallBack;
91+
System.SysUtils, System.Rtti, Vcl.Controls, Vcl.StdCtrls, Vcl.Forms, MethodCallBack;
92+
93+
type
94+
//https://github.com/Embarcadero/DelphiVCL4Python/issues/18
95+
TMemoStyleHookWA18 = class(TMemoStyleHook)
96+
strict private
97+
FParent: TScrollingStyleHook;
98+
strict protected
99+
procedure WndProc(var Message: TMessage); override;
100+
public
101+
constructor Create(AControl: TWinControl); override;
102+
destructor Destroy; override;
103+
end;
104+
105+
TScrollingStyleHookCrackerWA18 = class(TScrollingStyleHook)
106+
protected
107+
procedure WndProc(var Message: TMessage); override;
108+
end;
92109

93110
{ Global Functions }
94111

@@ -510,7 +527,43 @@ class procedure TPyDelphiCustomStyleServices.RegisterMethods(
510527
inherited;
511528
end;
512529

530+
{ TMemoStyleHookWA18 }
531+
532+
constructor TMemoStyleHookWA18.Create(AControl: TWinControl);
533+
begin
534+
inherited;
535+
FParent := TScrollingStyleHook.Create(AControl);
536+
end;
537+
538+
destructor TMemoStyleHookWA18.Destroy;
539+
begin
540+
FParent.Free();
541+
inherited;
542+
end;
543+
544+
procedure TMemoStyleHookWA18.WndProc(var Message: TMessage);
545+
begin
546+
case Message.Msg of
547+
WM_ERASEBKGND:
548+
begin
549+
TScrollingStyleHookCrackerWA18(FParent).WndProc(Message);
550+
end;
551+
else inherited;
552+
end;
553+
end;
554+
555+
{ TScrollingStyleHookCrackWA18 }
556+
557+
procedure TScrollingStyleHookCrackerWA18.WndProc(var Message: TMessage);
558+
begin
559+
inherited;
560+
end;
561+
513562
initialization
514563
RegisteredUnits.Add(TVclThemesRegistration.Create());
564+
TCustomStyleEngine.RegisterStyleHook(TMemo, TMemoStyleHookWA18);
565+
566+
finalization
567+
TCustomStyleEngine.UnRegisterStyleHook(TMemo, TMemoStyleHookWA18);
515568

516569
end.

0 commit comments

Comments
 (0)