Solved

Automatic scrolling when dragging over TScrollBox (Delphi)

Posted on 2007-11-29
3
992 Views
Last Modified: 2010-04-21
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?
0
Comment
Question by:plumothy
  • 2
3 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 20372282
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.
0
 
LVL 21

Accepted Solution

by:
ziolko earned 500 total points
ID: 20372548
...or even bettetr use ScrollBox.VertScrollBar.Position something like:

procedure TForm1.ScrollBox1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  Accept := Source is TTreeView;
  if Y < 15 then
    ScrollBox1.VertScrollBar.Position := ScrollBox1.VertScrollBar.Position - 8
  else if Y > ScrollBox1.Height  - 15 then
    ScrollBox1.VertScrollBar.Position := ScrollBox1.VertScrollBar.Position + 8;
end;

ziolko.
0
 

Author Closing Comment

by:plumothy
ID: 31411609
Perfect, thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now