lcl: make AutoScroll delphi compatible:

- set AutoScroll to False by default for TForm and TFrame. Leave it True for TScrollBox
  - allow AutoScroll change for forms with bsSizeable, bsSizeToolWin BorderStyle

git-svn-id: trunk@21478 -
This commit is contained in:
paul 2009-08-29 03:03:10 +00:00
parent b52f66dabc
commit 56c45690de
4 changed files with 42 additions and 40 deletions

View File

@ -159,7 +159,7 @@ type
function StoreScrollBars : Boolean; function StoreScrollBars : Boolean;
protected protected
class procedure WSRegisterClass; override; class procedure WSRegisterClass; override;
property AutoScroll: Boolean read FAutoScroll write SetAutoScroll default true; property AutoScroll: Boolean read FAutoScroll write SetAutoScroll default False;
procedure AlignControls(AControl: TControl; var ARect: TRect); override; procedure AlignControls(AControl: TControl; var ARect: TRect); override;
procedure CreateWnd; override; procedure CreateWnd; override;
function GetClientScrollOffset: TPoint; override; function GetClientScrollOffset: TPoint; override;
@ -197,7 +197,7 @@ type
property Align; property Align;
property Anchors; property Anchors;
property AutoSize; property AutoSize;
property AutoScroll; property AutoScroll default True;
property BorderSpacing; property BorderSpacing;
property BiDiMode; property BiDiMode;
property BorderStyle default bsSingle; property BorderStyle default bsSingle;
@ -428,13 +428,12 @@ type
function GetPixelsPerInch: Longint; function GetPixelsPerInch: Longint;
function GetRestoredLeft: integer; function GetRestoredLeft: integer;
function GetRestoredTop: integer; function GetRestoredTop: integer;
function IsAutoScrollStored: Boolean;
function IsForm: Boolean; function IsForm: Boolean;
function IsHelpFileStored: Boolean;
function IsIconStored: Boolean; function IsIconStored: Boolean;
procedure CloseModal; procedure CloseModal;
procedure FreeIconHandles; procedure FreeIconHandles;
procedure IconChanged(Sender: TObject); procedure IconChanged(Sender: TObject);
function IsKeyPreviewStored: Boolean;
procedure SetActive(AValue: Boolean); procedure SetActive(AValue: Boolean);
procedure SetActiveControl(AWinControl: TWinControl); procedure SetActiveControl(AWinControl: TWinControl);
procedure SetActiveDefaultControl(AControl: TControl); procedure SetActiveDefaultControl(AControl: TControl);
@ -574,6 +573,7 @@ type
property ActiveControl: TWinControl read FActiveControl write SetActiveControl; property ActiveControl: TWinControl read FActiveControl write SetActiveControl;
property ActiveDefaultControl: TControl read FActiveDefaultControl write SetActiveDefaultControl; property ActiveDefaultControl: TControl read FActiveDefaultControl write SetActiveDefaultControl;
property AllowDropFiles: Boolean read FAllowDropFiles write SetAllowDropFiles default False; property AllowDropFiles: Boolean read FAllowDropFiles write SetAllowDropFiles default False;
property AutoScroll stored IsAutoScrollStored;
property BorderIcons: TBorderIcons read FBorderIcons write SetBorderIcons property BorderIcons: TBorderIcons read FBorderIcons write SetBorderIcons
default [biSystemMenu, biMinimize, biMaximize]; default [biSystemMenu, biMinimize, biMaximize];
property BorderStyle: TFormBorderStyle property BorderStyle: TFormBorderStyle
@ -588,11 +588,9 @@ type
property FormState: TFormState read FFormState; property FormState: TFormState read FFormState;
property FormStyle: TFormStyle read FFormStyle write SetFormStyle property FormStyle: TFormStyle read FFormStyle write SetFormStyle
default fsNormal; default fsNormal;
property HelpFile: string read FHelpFile write FHelpFile property HelpFile: string read FHelpFile write FHelpFile;
stored IsHelpFileStored;
property Icon: TIcon read FIcon write SetIcon stored IsIconStored; property Icon: TIcon read FIcon write SetIcon stored IsIconStored;
property KeyPreview: Boolean read FKeyPreview write FKeyPreview property KeyPreview: Boolean read FKeyPreview write FKeyPreview default False;
stored IsKeyPreviewStored default False;
property Menu : TMainMenu read FMenu write SetMenu; property Menu : TMainMenu read FMenu write SetMenu;
property ModalResult : TModalResult read FModalResult write SetModalResult; property ModalResult : TModalResult read FModalResult write SetModalResult;
property Monitor: TMonitor read GetMonitor; property Monitor: TMonitor read GetMonitor;
@ -610,7 +608,7 @@ type
property OnShortcut: TShortcutEvent read FOnShortcut write FOnShortcut; property OnShortcut: TShortcutEvent read FOnShortcut write FOnShortcut;
property OnShow: TNotifyEvent read FOnShow write FOnShow; property OnShow: TNotifyEvent read FOnShow write FOnShow;
property OnWindowStateChange: TNotifyEvent property OnWindowStateChange: TNotifyEvent
read fOnWindowStateChange write fOnWindowStateChange; read FOnWindowStateChange write FOnWindowStateChange;
property ParentFont default False; property ParentFont default False;
property PixelsPerInch: Longint read GetPixelsPerInch write FPixelsPerInch stored False; property PixelsPerInch: Longint read GetPixelsPerInch write FPixelsPerInch stored False;
property Position: TPosition read FPosition write SetPosition default poDesigned; property Position: TPosition read FPosition write SetPosition default poDesigned;

View File

@ -20,6 +20,9 @@
{ $DEFINE CHECK_POSITION} { $DEFINE CHECK_POSITION}
const
FormStylesAllowAutoScroll = [bsSizeable, bsSizeToolWin];
{ TCustomForm } { TCustomForm }
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -186,14 +189,6 @@ begin
end; end;
end; end;
{------------------------------------------------------------------------------
function TCustomForm.IsKeyPreviewStored: boolean;
------------------------------------------------------------------------------}
function TCustomForm.IsKeyPreviewStored: boolean;
begin
Result:=FKeyPreview=true;
end;
procedure TCustomForm.SetCancelControl(NewControl: TControl); procedure TCustomForm.SetCancelControl(NewControl: TControl);
var var
OldCancelControl: TControl; OldCancelControl: TControl;
@ -260,15 +255,6 @@ begin
FModalResult:=AValue; FModalResult:=AValue;
end; end;
{------------------------------------------------------------------------------
Method: TCustomForm.IsIconStored
Returns: if form icon should be stored in the stream
------------------------------------------------------------------------------}
function TCustomForm.IsIconStored: Boolean;
begin
Result := IsForm and (Icon <> nil);
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Method: TCustomForm.BigIconHandle Method: TCustomForm.BigIconHandle
Returns: HICON Returns: HICON
@ -1326,6 +1312,11 @@ var
begin begin
if FFormBorderStyle = NewStyle then exit; if FFormBorderStyle = NewStyle then exit;
//TODO: Finish SETBORDERSTYLE //TODO: Finish SETBORDERSTYLE
// AutoScroll is only available for bsSizeable, bsSizeToolWin windows
if not (NewStyle in FormStylesAllowAutoScroll) then
AutoScroll := False;
AdaptBorderIcons := not (csLoading in ComponentState) and AdaptBorderIcons := not (csLoading in ComponentState) and
(BorderIcons = DefaultBorderIcons[FFormBorderStyle]); (BorderIcons = DefaultBorderIcons[FFormBorderStyle]);
FFormBorderStyle := NewStyle; FFormBorderStyle := NewStyle;
@ -1714,14 +1705,34 @@ begin
Result := False; Result := False;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------}
TCustomForm Method IsForm { Method: TCustomForm.IsAutoScrollStored }
------------------------------------------------------------------------------} { Returns: if form AutoScroll should be stored in the stream }
{------------------------------------------------------------------------------}
function TCustomForm.IsAutoScrollStored: Boolean;
begin
// store autoscroll only if BorderStyle allows this
Result := IsForm and (BorderStyle in FormStylesAllowAutoScroll);
end;
{------------------------------------------------------------------------------}
{ Method: TCustomForm.IsForm }
{ Returns: if form properties should be stored in the stream }
{------------------------------------------------------------------------------}
function TCustomForm.IsForm: Boolean; function TCustomForm.IsForm: Boolean;
begin begin
Result := True; Result := True;
end; end;
{------------------------------------------------------------------------------}
{ Method: TCustomForm.IsIconStored }
{ Returns: if form icon should be stored in the stream }
{------------------------------------------------------------------------------}
function TCustomForm.IsIconStored: Boolean;
begin
Result := IsForm and (Icon <> nil);
end;
function TCustomForm.GetPixelsPerInch: Longint; function TCustomForm.GetPixelsPerInch: Longint;
var var
ParentForm: TCustomForm; ParentForm: TCustomForm;
@ -1769,14 +1780,6 @@ begin
Result := FRestoredTop; Result := FRestoredTop;
end; end;
{------------------------------------------------------------------------------
function TCustomForm.IsHelpFileStored: boolean;
------------------------------------------------------------------------------}
function TCustomForm.IsHelpFileStored: boolean;
begin
Result:=FHelpFile<>'';
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
TCustomForm Method SetFocusedControl TCustomForm Method SetFocusedControl

View File

@ -25,6 +25,7 @@ constructor TScrollBox.Create(AOwner: TComponent);
begin begin
Inherited Create(AOwner); Inherited Create(AOwner);
fCompStyle:= csScrollBox; fCompStyle:= csScrollBox;
AutoScroll := True;
BorderStyle := bsSingle; BorderStyle := bsSingle;
end; end;

View File

@ -262,7 +262,7 @@ constructor TScrollingWinControl.Create(TheOwner : TComponent);
begin begin
Inherited Create(TheOwner); Inherited Create(TheOwner);
FAutoScroll := true; FAutoScroll := False;
FVertScrollbar := TControlScrollBar.Create(Self, sbVertical); FVertScrollbar := TControlScrollBar.Create(Self, sbVertical);
FHorzScrollbar := TControlScrollBar.Create(Self, sbHorizontal); FHorzScrollbar := TControlScrollBar.Create(Self, sbHorizontal);