CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 1999
    Location
    Los Angeles, CA
    Posts
    5

    Automatic Form Scrolling

    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.



  2. #2
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: Automatic Form Scrolling

    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

  3. #3
    Join Date
    Jul 1999
    Location
    Mumbai - India
    Posts
    12

    Re: Automatic Form Scrolling

    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 ([email protected])
    Date: 24 December 1998
    Requires: SSUBTMR.DLL

    ---------------------------------------------------------------------------
    Copyright ® 1998 Steve McMahon ([email protected])
    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 "[email protected]". Don't forget to mention my name in Subject area.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured