Click to See Complete Forum and Search --> : Automatic Form Scrolling


Freddie
November 29th, 1999, 06:21 PM
I have a long form contained within a picture box. I am using both horizontal and vertical scroll bars.
I would like to have my application automatically scroll when the cursor has
reached the edge of the screen. This would make it more practical from a
users standpoint. Currently, when the cursor reaches the edge of the screen,
the user has to manually slide the scroll bar.

Ravi Kiran
November 30th, 1999, 12:20 AM
see my other posting, also for your question
You can catch the GotFocus event and try to adjust the scrollbar value, which will automatically scroll the control into view

RK

Girish Chandra
November 30th, 1999, 01:24 AM
Hi Freddie,

I did manage to solve my problem "Scrolling Forms", but by using a crude method. While looking for information regarding my problem, I came across an ocx "cScrollBars" which attempted a solution for the same problem. I am giving details below.

Name: cScrollBars
Author: Steve McMahon (steve@dogma.demon.co.uk)
Date: 24 December 1998
Requires: SSUBTMR.DLL

---------------------------------------------------------------------------
Copyright ® 1998 Steve McMahon (steve@dogma.demon.co.uk)
Visit vbAccelerator - free, advanced source code for VB programmers.
http://vbaccelerator.com

However, I used a slightly different approach. I put a picture box on all my forms and created a set of functions to implement scrolling

SFAdd(xForm As Form,xFrame As Object) - Add a form for scrolling
SFDel(hWnd As Long) - Delete a window for scrolling

I maintained a separate array of forms to scroll and subclassed them in SFAdd() to do automatic scrolling. All I had to do is to call SFAdd() in Load event and SFDel() in UnLoad event. SFAdd() would automatically move all controls on the form into the object usually a PictureBox control specified with SFAdd() as xFrame. All handling for Form resize was handled automatically through the subclassed procedure.

That goes for my solution to my problem. As for your problem I wish that there was something akin to "FocusChanged" event wherein we could put code to scroll the window automatically, thus bringing the required window area into view. The closest we can simulate this functionality is by using a Timer to trigger at regular intervals and see if the ActiveControl on the form is visible or not. If the control is not visible we can scroll the window ourselves without bothering the user, just as you want it.

Please let me know if my suggestion works, I haven't yet tried it. I would also like to implement this functionality, now that you have mentioned it.

Best Of Luck,

Girish Chandra

PS: You can get to me directly by e-mailing at "sipl@vsnl.com". Don't forget to mention my name in Subject area.