Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setveiwport vertically scrollable form 1

Status
Not open for further replies.

SMCmtg

Programmer
Mar 27, 2000
90
0
0
US
The legal size form I have with vertical scroll bar with fields/data beyond the viewable desktop.

Form is:

In top level
top=20
left=0
width=788
height= viewable 540 scrollable 1180

How do you handle setting viewport as you tab or click on the fields thru out the form. That is tab over tab or around the form by scroll and click. . .?
Any feedback would be appreciated.
THX

Bill
 
Bill,
I saved off the following message from back in February 2000 in the newsgroups, just in case I was ever "foolish" enough to try a scrolling form. I don't know if any of the problems described were resolved since then, but here it is, for what it's worth.

Rick

"As Mike said, the useable height of the form is limited to about 1150 pixels (I've found this to be 1173 pixels).
Once you place objects further down than 1173 pixels from the top of the form (ie the object's top property is > 1173), you run into the sort of problems you described.

I haven't experimented with how far to the right you can get away with placing objects, since all my form objects are no further than 816 pixels from the left of the form.

Objects do not automatically come in to view when they receive the focus (ie the form doesn't automatically scroll to bring the object into the form's viewport).
This requires a little work, but not much. Subclass all the controls you intend to use in your scrollable form. In the When or Gotfocus events of the subclassed controls, place the follwing code (adjusted to your needs):

*<Begin code>
LOCAL lnVPTop,lnVPHeight,lnVPLeft,lnNewTop,lgAdjTop,lgAdjLeft,lnNewLeft
lnVPTop=ThisForm.ViewPortTop
lnVPHeight=ThisForm.ViewPortHeight-16 && takes into account form's title bar
lnVPLeft=ThisForm.ViewPortLeft
lnNewTop=lnVPTop
lnNewLeft=lnVPLeft

IF (20+This.Top)>(lnVPTop+lnVPHeight)
lnNewTop=lnVPTop+(20+This.Top)-(lnVPTop+lnVPHeight)
lgAdjTop=.T.
ENDIF

IF This.Top<lnVPTop
lnNewTop=This.Top
lgAdjTop=.T.
ENDIF

IF This.Left<lnVPLeft
lnNewLeft=This.Left
lgAdjLeft=.T.
ENDIF

IF lgAdjLeft OR lgAdjTop
ThisForm.SetViewPort(lnNewLeft,lnNewTop)
ENDIF
*<End Code>

This is a &quot;basic&quot; approach. For option groups, command groups, grids it would be better to ensure that the whole container control is visible.
The '20' constant can be substituted with the control's height. (I used this for large editboxes which were taller than the form's viewportheight).&quot;
 
Hey Rick, thanks tons, I looked all over. . .
this looks like a work thru. . .
you and who ever wrote that article desire 2 stars. . .
thanks for responding.:-D
Bill
 
Rick: I worked this code out thanks to your help!

Max Height is 1200 and max width is 1600 with vertical and hoz scroll bars. Bottom right hand corner of this would be: Textbox example, Height 20, top 1580, width 100, left 1500. . .that give a ton of work space. . .I put it in the when event of class textbox. . .
********the code you posted works great, I had to add some. . .and modifed. .

LOCAL lnVPTop,lnVPHeight,lnVPLeft,lnNewTop,lgAdjTop,lgAdjLeft,lnNewLeft,lnVPwidth
lnVPTop=ThisForm.ViewPortTop
lnVPHeight=ThisForm.ViewPortHeight-16 && takes into account form's title bar
lnVPwidth=thisform.ViewPortWidth
lnVPLeft=ThisForm.ViewPortLeft
lnNewTop=lnVPTop
lnNewLeft=lnVPLeft
IF (20+This.Top)>(lnVPTop+lnVPHeight)
lnNewTop=lnVPTop+(20+This.Top)-(lnVPTop+lnVPHeight)
lgAdjTop=.T.
ENDIF
IF This.Top<lnVPTop
lnNewTop=This.Top
lgAdjTop=.T.
ENDIF

&&&&added this portion to get the horz to work. . .
IF (20+This.left)>(lnVPleft+lnVPwidth)
lnNewleft=lnVPleft+(120+This.left)-(lnVPleft+lnVPwidth)
lgAdjleft=.T.
ENDIF
&&&&&&&&&&&&&

IF This.Left<lnVPLeft
lnNewLeft=This.Left
lgAdjLeft=.T.
ENDIF
IF lgAdjLeft OR lgAdjTop
ThisForm.SetViewPort(lnNewLeft,lnNewTop)
ENDIF

Now if I can figure out how to give you a star, I will be up to speed. . .
Thanks anyway, its much appreciated!
Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top