Solved

Fox pro 9  Auto scrolling through forms

Posted on 2010-09-11
7
700 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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 your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 will show you how to create an ISO CD-ROM/DVD-ROM image (*.iso), and MD5 checksum signature, for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5). It's a good idea to compare checksums, because many installations fail because of a corr…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

12 Experts available now in Live!

Get 1:1 Help Now