Solved

Fox pro 9  Auto scrolling through forms

Posted on 2010-09-11
7
702 Views
Last Modified: 2012-05-10
I use the following validation routine and it works great


IF  EMPTY(thisform.txtweight.value)
=messagebox(" There is a problem with Weight  Click on OK to check it")
thisform.txtweight.setfocus
rETURN
endif

The cursor is sent to the text box that needs attention.

This is a large form the the user has to scroll up or down to find where the cursor went. Is there a way to have the form automatically  scroll to the location of the text box after the set focus command is given?? Would save alot of time for us.

Thank You

D
0
Comment
Question by:Malibucompany
  • 3
  • 3
7 Comments
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 251 total points
ID: 33653420
Witout testing, SetViewPort() should set the upper left position of the visible portion of a scrollable form.

But why creating forms that need to scroll at all? Putting controls on pages of a pageframe you can easily se tthe active page. Also I'd rather use something like below. Setting all controls to a yellow background color that have an invalid value. That will give an overview of what is wrong in one pass. Imagine someone enters wrong values for more than one control, and that's likely in a large form, you'll need to submit each time you corrected one field to see the next one being wrong. That's what's even more inefficient than not scrolling to the control with the wrong value.

Of course it would be nice to set focus to the first control with a wrong value, therefore you could set some variable loFocusControl to the contrl you want to set focus to but only  do so after checking all values.

You can also set the background color back to normal with this.ResetToDefault("Backcolor") in the interactive change event of controls.

Bye, Olaf.
IF EMPTY(thisform.txtweight.value)
*=messagebox(" There is a problem with Weight  Click on OK to check it")
thisform.txtweight.backcolor = rgb(255,255,192)
Endif
...

Open in new window

0
 
LVL 29

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 251 total points
ID: 33653772
Tested now, SetViewport is correct, in a scrollable form it sets the upper left corner of the viewable portion of the form. You can call that method with 0 as nLeft and with the control.top as the nTop parameter to scroll to that control. If the control is not directly on the form but on a page of a pageframe or in a container obejct, you can use OBJTOCLIENT() to find the position of the control in reference to (0,0) upper left corner of the form.

Bye, Olaf.
0
 
LVL 2

Assisted Solution

by:FEOX
FEOX earned 249 total points
ID: 33667448
Try this:
IF (EMPTY(thisform.txtweight.value))

  =messagebox("There is a problem with Weight.  Click on OK to check it.")

  thisform.setviewport(0,thisform.txtweight.top-5)  && setviewport to txtweight

  thisform.txtweight.setfocus

  RETURN

ENDIF

Open in new window

0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:Malibucompany
ID: 33678179
Those solutions work great.  What I want to do in additon is to change the color of the border around the text box and perhaps the thickness of it.

I use this text
IF (EMPTY(thisform.txtweight.value))
  =messagebox("There is a problem with Weight.  Click on OK to check it.")
  thisform.setviewport(500,thisform.txtweight.TOP-200)  && setviewport to txtweight
    thisform.txtweight.backcolor = rgb(128,128,255)
    thisform.txtweight.bordercolor = rgb(255,255,255)
    thisform.txtweight.FOREcolor = rgb(255,255,255)
    thisform.txtweight.setfocus
  RETURN
ENDIF


The color of the border does not change. Any ideas why.

Thank You

D
0
 
LVL 2

Assisted Solution

by:FEOX
FEOX earned 249 total points
ID: 33678512
By default, the TextBox SpecialEffect setting is 0 (render as 3D).  With this setting, VFP and Windows handles the rendering of the 3D effect and the BorderColor setting will have no effect on the TextBox.

Setting the TextBox SpecialEffect setting to 1 (render as Plain) displays the border whose color can be controlled by the BorderColor setting. Just make sure BorderStyle is set to 1 (Fixed Single).  Otherwise, no Border will appear when this is set to 0 (which means None).

Try this:
THISFORM.TxtWeight.SpecialEffect = 1  && Plain (show Border)

THISFORM.TxtWeight.BorderStyle   = 1  && Fixed Single (make sure it has a border)

THISFORM.TxtWeight.BorderColor   = RGB(255,255,255)THISFORM.TxtWeight.ForeColor     = RGB(255,255,255)THISFORM.TxtWeight.BackColor     = RGB(128,128,255)

Open in new window

0
 
LVL 2

Assisted Solution

by:FEOX
FEOX earned 249 total points
ID: 33678521
For some reason, the code did not attach correctly.  Here is the corrected code:
THISFORM.TxtWeight.SpecialEffect = 1  && Plain (show Border)

THISFORM.TxtWeight.BorderStyle   = 1  && Fixed Single (make sure it has a border)

THISFORM.TxtWeight.BorderColor   = RGB(255,255,255)

THISFORM.TxtWeightForeColor      = RGB(255,255,255)

THISFORM.TxtWeight.BackColor     = RGB(128,128,255)

Open in new window

0
 
LVL 29

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 251 total points
ID: 33684943
FEOX has it right. To change the border width isn't possible, though. Only controls with a BorderWidth setting can have a thick border, mainly that is shape, container, line control, not databound controls like grid, listbox, editbox, textbox, combobox. You could perhaps make it slightly bigger, eg lower left and top by 1 or 2 and raise width and height by 2 or 4.

Bye, Olaf.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now