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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Focus in Browse Window 2

Status
Not open for further replies.

SuperBob

Technical User
Sep 18, 2001
23
GB
I have been asked to make a "useability" change to a VFP 6.0 program. this consists of a form whoch calls another program thet has a "DO Form" in it. The second form itself runs the following code:

SELECT ordrdata
SET ORDER TO TAG recnum
GO TOP
BROWSE NORMAL NOWAIT NODELETE NOEDIT NOAPPEND SAVE PREFERENCE 'Ordrdata' ;
TITLE 'Product Selection' ;
FIELDS LINE:H='LINE',qty:H='QTY', part_no:H='PART No.', ;
DESC:H='Description',vatcode:H='VAT',sell_price:H='Retail', vat:H='VAT%',;
disc:H='Disc%', apply_trad:H='Trade',ltotal,goodstot,vattot,ordername ;
KEY m.recnum
SCATTER MEMVAR

which displays a browse window. I have been asked to make the focus move to the first field in the next line of the Browse window each time a "Save" button is hit on ths form.

As a novice I am not sure how to make the Browse window take focus, let alone how to move the focus onto a specifi row in the window.

All help appreciated.
 
First, Why browse? Why not a normal form with Grid in it?
But to your question:
In Click event of the Save Button:
Code:
*** Move to next record
SKIP IN OrdData
IF EOF("OrdData") && If eof state stay on last record
   SKIP -1 IN OrdData
ENDIF
** Activate Browse window
ACTIVATE WINDOW "Product Selection"
unfortunately I don't know how to go to the first field, becuase I never use BROWSE, I use Grid where I have more control over the object.

Borislav Borissov
 

SuperBob,

I agree totally with Borislav that you should use grids rather than browses. However, in this case, that would be a long-term solution to a short-term problem. Obviously, your user wants a quick change to be made without you re-engineering your user interface.

So, in your Save button, do something like this:

ACTIVATE WINDOW ordrdata
KEYBOARD "{CTRL+DOWN}"

That'll move the highlight down one row. You need another KEYBOARD command to move it to the left-most column. I'm not sure which key does that (CTRL+HOME maybe? ) -- but someone else might be able to tell you that.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Thanks both, the advice was useful. As commented, if this was to be written anew, then using Browse would not be part of the solution!
 
I don't think there are very many short-cut keys that actually work with VFPs browse.

{CTRL-END} actually closes the window.

None of the other obvious ones do much at all - watch out for {Alt combinations too, you can end up accidently editting your data with extended character sets.

You even have to use the scroll bars to move to the beginning and end of the data.

Pity

Regards

Griff
Keep [Smile]ing
 

OK, how about something like this (not tested):

Code:
* ----
* Init
BROWSE NORMAL NOWAIT NODELETE NOEDIT NOAPPEND SAVE PREFERENCE 'Ordrdata' ;
   TITLE 'Product Selection' ;
   FIELDS LINE:H='LINE',qty:H='QTY', part_no:H='PART No.', ;
   DESC:H='Description',vatcode:H='VAT',sell_price:H='Retail', vat:H='VAT%',;
   disc:H='Disc%', apply_trad:H='Trade',ltotal,goodstot,vattot,ordername ;
   KEY m.recnum [b]NAME grdOrders[/b]
*
* -----------
*
* Save
lnRow = grdOrders.ActiveRow
grdOrders.ActivateCell(lnRow+1,1)

In other words, use the NAME clause to make the browse into an object, then use the properties and methods shown above to manipulate the highlight.

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Mike,

I just tested that approach - in VFP 6 - and it works rather well... from the command window I typed:

Code:
use MyTable
browse name fidget

Then I tried the following:
Code:
? fidget.activerow
? fidget.activecolumn


BUT, you can't activate a row outside the window - i.e.
Code:
fidget.activatecell(200,3)

Will probably result in the hight staying put or moving to column 3.

SO, to do what you suggest, try:
Code:
lnRow = fidget.ActiveRow
fidget.ActivateCell(lnRow,1)
Keyboard "{DnArrow}"

Nicely spotted trick though!


Regards

Griff
Keep [Smile]ing
 
Hi Mike,

That doesn't seem to work - VFP 6 throws an error on the active window - but it isn't critical. The thing I was trying to say was that the activatecell doesn't work like a spreadsheet, it's not absolute in its addressing, it works relative to the *current* top left cell.

so activatecell(1,1) always goes to the first column of the record displayed on row one of the current window so if the window is scrolled to the right (i.e. the cell at column one is not field one) you don't get field one... if you follow me?

Martin


Regards

Griff
Keep [Smile]ing
 
A small point of interest. In version 9 {CTRL-END} takes you to the last row (of the table rather than the browse window), with the cursor remaining in the column it was before Ctrl+End.

This functionality also works in grids.

Stewart
 
Stewart,

Interestingly, in version 9, {CTRL-HOME} works in a similar way - definately not in version 6 though B-(

Well spotted

Martin


Regards

Griff
Keep [Smile]ing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top