Einzelnen Beitrag anzeigen

entwickler-tbdevelop.com

Registriert seit: 25. Sep 2008
1 Beiträge
 
#7

Re: ScrollBar bei DBGrid immer anzeigen

  Alt 25. Sep 2008, 14:47
Hi, this is similar & works well:

Delphi-Quellcode:
unit ScrollDBGrid;

interface

uses
   Windows,
   Messages,
   StdCtrls,
   DbGrids;

type

   TScrollDBGrid = class(TDbGrid)
   private
      FAlwaysScroll: TScrollStyle;
      procedure SetAlwaysScroll(const Value: TScrollStyle);
      procedure WMNCCalcSize(var Msg: TMessage); message WM_NCCALCSIZE;
   published
      property   AlwaysScroll: TScrollStyle
                     read FAlwaysScroll
                     write SetAlwaysScroll
                     default ssNone;
   end;

implementation

{ TFlexibleScrollDBGrid }

procedure TScrollDBGrid.SetAlwaysScroll(const Value: TScrollStyle);
begin

   if not (FAlwaysScroll = Value) then
   begin

      FAlwaysScroll := Value;

      RecreateWnd;

   end;

end;


procedure TScrollDBGrid.WMNCCalcSize(var Msg: TMessage);
var
   NewStyle: Integer;
begin

   NewStyle := GetWindowLong(Handle, GWL_STYLE);

   if ([ScrollBars, FAlwaysScroll] * [ssHorizontal, ssBoth] <> []) then
      NewStyle := NewStyle or WS_HSCROLL;

   if ([ScrollBars, FAlwaysScroll] * [ssVertical, ssBoth] <> []) then
      NewStyle := NewStyle or WS_VSCROLL;

   SetWindowLong(Handle, GWL_STYLE, NewStyle);

   inherited;

end;


end.
Best regards.

(jope)
  Mit Zitat antworten Zitat