This is what i have done to make a Styled Grid behave like the non styled grid when scrolling.
unit xStyleFixes;
interface
uses forms, Vcl.Buttons, Vcl.StdCtrls, Windows, Messages, SysUtils, Classes, Graphics, Controls, themes, Wwdbgrid, typinfo, DBGrids;
type
TFixScrollingStyleHook = class (TScrollingStyleHook)
var ScrollBarthumbBtnWasPressed : Boolean;
procedure WMVScroll(var Msg: TMessage); message WM_VSCROLL;
end;
implementation
procedure TFixScrollingStyleHook.WMVScroll(var Msg: TMessage);
var sTest : String;
begin
if VertSliderState = tsThumbBtnVertPressed then begin
ScrollBarthumbBtnWasPressed := true;
Handled := True;
end else begin
if ScrollBarthumbBtnWasPressed then begin
if Self.VertTrackRect.TopLeft = self.VertSliderRect.TopLeft then
TWMVScroll(Msg).ScrollCode := SB_TOP;
if Self.VertTrackRect.BottomRight = self.VertSliderRect.BottomRight then
TWMVScroll(Msg).ScrollCode := SB_BOTTOM;
ScrollBarthumbBtnWasPressed := False;
end;
CallDefaultProc(TMessage(Msg));
PaintScroll;
end;
end;
initialization
TCustomStyleEngine.RegisterStyleHook(TWWDbGrid, TFixScrollingStyleHook );
TCustomStyleEngine.RegisterStyleHook(TDbGrid, TFixScrollingStyleHook );
end.
This is my first time playing with Style hooks so if you can see a better way to do this please let me know