?
Solved

Fox pro 9  Auto scrolling through forms

Posted on 2010-09-11
7
Medium Priority
?
709 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
[X]
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
  • 3
  • 3
7 Comments
 
LVL 30

Accepted Solution

by:
Olaf Doschke earned 1004 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 30

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 1004 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 996 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 996 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 996 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 30

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 1004 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

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…
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

764 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