Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SetFocus/GotFocus question

Status
Not open for further replies.

PBREP

MIS
Mar 14, 2003
75
US
Good afternoon Foxpro Gurus:

Trying to implement Function or Procedure for a SetFocus or GotFocus. After the user double-clicks the CustId and selects their customer id (sc_ship.a_cus[1] I need my cursor to automatically move into another textbox (sa_cust[1]) field/array. How can I implement this in VFP 5.0?

Thanks,
PM
 
You should be able to return a 1 In your valid event to move to the next field.


Dave S.
[cheers]
 
Hello Dave:

Can you elaborate a little or an example? I might need more coffee here :)

Procedure SetFocus

sa_cust[1] = 1

endproc

Thanks,
PM
 
PM,
The GotFocus() and LostFocus() Event methods are called when the user tabs or click into or out of the control.

You can use the SetFocus() to change the normal tab order order from anywhere but the When() and Valid() methods. So in the DoubleClick() method of the control where your CustID is, you'd need to add the code:
Code:
ThisForm.txtSa_Cust.SetFocus()
Note: You need the name of the textbox not the controlsource value.

Rick
 
Hi Rick:

Thanks for the input. Unfortunately, I do not have access to the control form. The only access I have to create any modification is from a .prg file. Therefore only Functions, Commands, Procedures are allowed. The Arrays values are all I have to work with, that is why all my posts are somewhat odd.

Any other suggestions would be appreciated.

Thanks,
PM
 
PM,
The "rules" are the same - whether you write the code in a program or use the form designer. Can you post the relavent program code you need to modify?

Rick
 
PM,
The "rules" are the same - whether you write the code in a program or use the form designer. Can you post the relavent program code you need to modify?

Rick


Hi Rick:

Not really because this is something I am attempting to create from scratch within the .prg file. See the program file is like arepository that hls all your stuff :) There is a toll call Screen builders that allows you to add fields and tags to call a Keyboard Shortcut, Foxpro Command, Function, Run External program. Again, all I have to work with is the arrays.

sc_ship.a_cus[1] <- after this field is populated with data, I need a setFocus or getFocus to this field->sa_cust[1]

Thanks,
PM
 
PM,
The &quot;rules&quot; are the same - whether you write the code in a program or use the form designer. Can you post the relavent program code you need to modify?

Rick


Hi Rick:

Not really because this is something I am attempting to create from scratch within the .prg file. See the program file is like arepository that hls all your stuff :) There is a toll call Screen builders that allows you to add fields and tags to call a Keyboard Shortcut, Foxpro Command, Function, Run External program. Again, all I have to work with is the arrays not the Control form i.e. Load()
Init()
Show()
Activate()
GotFocus()

sc_ship.a_cus[1] <- after this field is populated with data, I need a setFocus or getFocus to this field->sa_cust[1]

Thanks,
PM
 
I think there is a bit of clearing up required.

I don't think you are asking the correct question and/or
leaving out some pertinent details vis-a-vis your problem.

Are you saying you want to create control method calls via the arrays?

If so, there are a number of ways to accomplish this and
normally they are driven with temporary or permanent
cursors, but arrays will work just as well. And as might
be expected; if what I ask is accurate; you need to
generate the appropriate code to access the controls
'on the fly'.

Bottom line is - you need to know the names of the controls
on the form(s) in order to manipulate them and as implied
in the above this can be determined at run-time without
knowing in advance the control names. This is the case
regardless of whether they are hard- coded, driven by a
table, or driven by an array.


A couple of questions:

Is there a line in the program that invokes a form?
i.e. Do form formxyx
(where formxyz is an argument to the do form command)

-Or-

Is the form being created programmatically?
i.e. Something like the following:

define class formxyz as form

* a bunch of code here

enddefine


As stated, you'll need to provide some additional info.

You can determine the controls on the form(s) at
run-time with something like the following code, but I
think we are still unclear as to what your actual problem
is.

Also, you can modify the following to just return the
controls on the form under investigation.

Darrell


* This will create a series of arrays which contain
* the control names of the controls on all active
* forms. Note: This will not list the controls in
* container classes. There are more effiecient
* ways of accomplishing this, but this should suffice
* for simple cases

LOCAL ARRAY laForms[1]
LOCAL loForm, lcMac, i, j

FOR i = 1 TO _SCREEN.FORMCOUNT

loForm = _SCREEN.FORMS(i)
WITH loForm

DIME laForms[ i ]

laForms[ i ] = loForm.NAME

lcMac = &quot;local array la&quot;+laForms[ i ]+&quot;[&quot;+STR(loForm.controlcount)+&quot;]&quot;
&lcMac

FOR j = 1 TO loForm.CONTROLCOUNT
lcMac = &quot;la&quot; + loForm.NAME + &quot;[&quot; +STR(j) +&quot;] = loForm.controls(&quot;+STR(j)+ &quot;).name&quot;
&lcMac
NEXT
ENDWITH
NEXT

susp


'We all must do the hard bits so when we get bit we know where to bite' :)
 
Hello Darrell:

There is not concrete code I can show you i only can provide the arrays I'm working with. In simple turns, after the shipping processing screen (Sh_main.prg - viewed in debug)launches, the user would doubl-click in the customer ID field (sc_ship.a_cus[1]); After this field is populated 9i.e. 1005), I want to move the cursor to a text box (sa_cust[1]) I created on this screen (I do have the capibility to add fields) thats it. :)

The CUS_MAIN.prg is used to store used defined functions.
This program file will be loaded during system initialization so that all functions within the file will be available for the user to access execute VFP functions.

The function CUS_INIT will be called during system initialization. The function CUS_END will be called when user exits the system.

The user can add his own functions and also SET PROCEDURE to another FXP files that include more functions.

Are you saying you want to create control method calls via the arrays? = Yes

Is there a line in the program that invokes a form? = Yes, but hardcoded

Is the form being created programmatically? = yes, but harcoded

thanks you,
PM



 
I'd say you have all the information needed to accomplish
what you desire.

You just need to figure out how to map the array contents
to the controls they are associated with.

I'm still unsure as to what your quandry is. You have all
the information required at your finger tips.

Darrell



'We all must do the hard bits so when we get bit we know where to bite' :)
 
Also, since this seems to be a dymanic programming model,
it'll be helpful if you research the subject of 'patterns'.

Especially the concepts of &quot;Abstract Factory Models',
'Delegates', and 'Hook objects'.

Although it's probably not necessary for the program complexity this appears to be, you'll definitely want to
develop some type of formal analysis and design
methodology if it gets any more convoluted.

I live by rule of: &quot;First turn the computer off and work
on paper&quot;, when approaching a complex design issue.

Darrell


'We all must do the hard bits so when we get bit we know where to bite' :)
 
Hi Darrell:

Yes I have the information but all the examples I'd looked at show using Setfocus or GotFocus at the source of the form during development. So, since I do not have access I was looking to see if anyone out there done something similiar within a Function.

Something along the lines like...

Function Move_Cursor()
If sc_ship.a_cus[1] = &quot;&quot; && equals something
CursorLocation = sa_cust[1]

endif
endfunc

Thanks,
PM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top