Solved

Auto Scroll

Posted on 1999-01-03
11
392 Views
Last Modified: 2010-04-04
Hi,
I'm using a scrollbox with a TImage component. How do I make the scrollbox autoscroll to the right direction, when I arrive the Border of it ? I want that the point you are editing of the image is visible while editing. E.g. the user of my program wants to draw a rectangle. The problem is that he cannot see the size of it, when the image size is bigger than the size of the scroll box.
0
Comment
Question by:ItsMe
  • 6
  • 5
11 Comments
 
LVL 3

Expert Comment

by:Matvey
ID: 1354285
Just check the mouse events and coordinates, and calculate the delta X and Y to scroll.
You can also find various image components on the Delphi pages that have built in scrolling...
0
 

Author Comment

by:ItsMe
ID: 1354286
OK, I know the mouse Coords (the position on the image) but
how do I know if they are in the visible area of the scrollbox ?
The user klicks (holds) and pulls the mouse to draw a rectangle circle etc.
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1354287
I think it's best to check if the cursor reached the edges and going beyond them. It's hard to imagine the thing you've set up here - can you tell more, or even post the unit?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:ItsMe
ID: 1354288
The example from Borland (Graphex) is the same like mine.
0
 

Author Comment

by:ItsMe
ID: 1354289
... the same principle ...
0
 

Author Comment

by:ItsMe
ID: 1354290
Help !

0
 
LVL 3

Expert Comment

by:Matvey
ID: 1354291
Sorry...
I still haven't installed Delphi 4 (Graphex?). Post whatever you have, and explain what doesn't work. Sorry...
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1354292
Send it please to me <bosism@netvision.net.il>
0
 

Author Comment

by:ItsMe
ID: 1354293
Graphex is included in Delphi 3 in the Demos\Doc\Graphex
directory. Graphex is an paint example. My problem is that
when I want to draw e.g. a  rectangle which becomes bigger
than the visible part of the image the scrollbox doesn't
scroll. I need to know how I can make the scrollbox scroll
when I arrive one of her edges/borders.
0
 
LVL 3

Accepted Solution

by:
Matvey earned 20 total points
ID: 1354294
Ahm... teehee, I have never seen this example! I guess you helped me discover something new too :)

OK. There are two methods to implement scrolling the drawing point into view. They are only different visually: one is

________________________________________________________________
procedure TForm1.ScrollPointInView(p: TPoint);
begin
  with scrollbox1 do begin
    with HorzScrollBar do
           if (p.x < Position) then Position := p.x
      else if (p.x > position + clientwidth) then Position := p.x - clientwidth;
    with VertScrollBar do
           if (Position > p.y) then Position := p.y
      else if (p.y > position + clientheight) then Position := p.y - clientheight;
  end;
end;

...............................

procedure TForm1.DrawShape(TopLeft, BottomRight: TPoint; AMode: TPenMode);
begin

  ScrollPointInView(BottomRight);

..................
end;
________________________________________________________________

Another method involves a timer, and the image is scrolled smoothly, incrementing the position by one (just a different effect).

Good luck and a happy new year!
--Matvey
0
 

Author Comment

by:ItsMe
ID: 1354295
Thank you ! It works very well.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 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