Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Automatic scrolling when dragging over TScrollBox (Delphi)

Posted on 2007-11-29
3
Medium Priority
?
1,019 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

670 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