Solved

Auto Scroll

Posted on 1999-01-03
11
394 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
code issue 8 184
Printing problem 2 110
Firemonkey DbLookupComboBox equivalent ? 2 67
How to remove Recent Projects from Embarcadero C++ builder XE10. Berlin 2 78
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…

756 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