Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Automatic scrolling when dragging over TScrollBox (Delphi)

Posted on 2007-11-29
3
Medium Priority
?
1,027 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

886 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