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

x
?
Solved

Auto Scroll

Posted on 1999-01-03
11
Medium Priority
?
402 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 80 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

824 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