Solved

Automatic scrolling when dragging over TScrollBox (Delphi)

Posted on 2007-11-29
3
1,014 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 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month7 days, 8 hours left to enroll

632 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