Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Fox pro 9  Auto scrolling through forms

Posted on 2010-09-11
7
704 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

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…
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 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