The auto scrolling is generated by the function AutoScrollInView, which is called from the SetFocusedControl function (which is called when you change focus, like clicking in the other grid). You can disable this by deriving the TScrollBox class locally in your unit, with the same name, and then override the AutoScrollInView with an empty function. I don't know if it is the best way to do it in this case, but it works.
Setting the TScrollBox.AutoScroll property to false prevents auto scrolling, but it also removes the scroll bars, and I don't think that's what you are looking for.
regards
Hypo
Main Topics
Browse All Topics





by: rllibbyPosted on 2009-05-12 at 07:53:33ID: 24365240
You can create a component derived by TScrollBox, and then override the TScrollingWinControl.AutoS crollInVie w.
------
TControl); override;
iew(AContr ol: TControl);
, [TScrollBoxEx]);
Eg:
--------------------------
unit ScrollBoxEx;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TScrollBoxEx = class(TScrollBox)
private
// Private declarations
protected
// Protected declarations
procedure AutoScrollInView(AControl:
public
// Public declarations
published
// Published declarations
property Align;
property Anchors;
property AutoScroll;
property AutoSize;
property BiDiMode;
property BorderStyle;
property Constraints;
property DockSite;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Color nodefault;
property Ctl3D;
property Font;
property ParentBiDiMode;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property OnCanResize;
property OnClick;
property OnConstrainedResize;
property OnContextPopup;
property OnDblClick;
property OnDockDrop;
property OnDockOver;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGetSiteInfo;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnMouseWheel;
property OnMouseWheelDown;
property OnMouseWheelUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
property OnUnDock;
end;
procedure Register;
implementation
procedure TScrollBoxEx.AutoScrollInV
begin
// No-op
end;
procedure Register;
begin
RegisterComponents('Win32'
end;
end.
-------------------
- Save component source
- Install the component
- Change the dfm (view as text) to read:
object ScrollBox1: TScrollBoxEx
- Change the form declaration to read
type
TForm1 = class(TForm)
ScrollBox1: TScrollBoxEx;
----------
Regards,
Russell