Solved

Fox pro 9  Auto scrolling through forms

Posted on 2010-09-11
7
705 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 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
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
dedupe in foxpro 12 472
Data Import from a CSV file 8 502
Alternative to "Do While" 12 166
Can a CDX FoxPro file be opened by another application 10 204
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…
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

733 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