【问题标题】:Delphi Style issue TDBGrid Vertical Scroll choppy when scrollingDelphi Style 问题 TDBGrid Vertical Scroll 滚动时断断续续
【发布时间】:2015-05-22 05:35:36
【问题描述】:

我正在使用应用了样式的 Delphi XE5。

当使用具有足够记录来显示垂直滚动条的 DBGrid 时,单击并拖动滚动条会导致动画不连贯。网格不断重绘/更新。

如果我将 DBGRID.StyleElement.seBorder 设置为 False,它会正常运行,例如您可以将滚动条拖到顶部或底部,而无需更改/重新绘制网格,直到您松开鼠标按钮。

有没有什么方法可以让样式开启时垂直滚动条的行为?

【问题讨论】:

    标签: delphi vcl vcl-styles tdbgrid


    【解决方案1】:

    这就是我所做的,以使样式化网格在滚动时表现得像非样式化网格。

    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,所以如果你能找到更好的方法,请告诉我

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-27
      相关资源
      最近更新 更多