Link to home
Start Free TrialLog in
Avatar of plumothy
plumothyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Automatic scrolling when dragging over TScrollBox (Delphi)

In my Delphi application I have a TScrollBox with only the vertical scroll bar enabled.

When the scroll box is too small for its contents then the vertical scroll box appears automatically - that's fine.

I would like the scrollbox to automatically scroll up and down as necessary when the user drags an object over it (so they can find the right place to drop it).

Does anyone know how to achieve this?
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

try this:

procedure TForm1.ScrollBox1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
var calcX, calcY: Integer;
begin
  //calcX, calcY calculate how you want it to scroll
  ScrollBox1.ScrollBy(calcX, calcY);
end;


ziolko.
ASKER CERTIFIED SOLUTION
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of plumothy

ASKER

Perfect, thanks