我正在使用应用了样式的 Delphi XE5。
当使用具有足够记录来显示垂直滚动条的 DBGrid 时,单击并拖动滚动条会导致动画不连贯。网格不断重新绘制/更新。
如果我将 DBGRID.StyleElement.seBorder 设置为 False,它会正常运行,例如,您可以将滚动条拖到顶部或底部,而无需更改/重新绘制网格,直到您松开鼠标按钮。
当样式打开时,有什么方法可以使垂直滚动条起作用?
我正在使用应用了样式的 Delphi XE5。
当使用具有足够记录来显示垂直滚动条的 DBGrid 时,单击并拖动滚动条会导致动画不连贯。网格不断重新绘制/更新。
如果我将 DBGRID.StyleElement.seBorder 设置为 False,它会正常运行,例如,您可以将滚动条拖到顶部或底部,而无需更改/重新绘制网格,直到您松开鼠标按钮。
当样式打开时,有什么方法可以使垂直滚动条起作用?
这就是我为使样式化网格在滚动时表现得像非样式化网格所做的工作。
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.
这是我第一次玩 Style hooks,所以如果你能找到更好的方法,请告诉我