define window
Thanks for any help
Amado
Thanks for any help
Amado
Local oForm oForm = CREATEOBJECT("TopForm")oForm. show()_screen .Visible = .F. && Hide Screen*!* we're going to define our window as being "IN WINDOW TopLevelForm" DEFINE WINDOW DefinedWindow AT 1, 15 SIZE 15, 25 IN WINDOW TopLevelForm TITLE "Defined Window" CLOSE FLOAT GROW ZOOM*!* If we hadn't defined our window as being "IN WINDOW TopLevelForm", we could *!* still put it in the Top Level Form by using "IN WINDOW TopLevelForm" clause in our *!* activate command below ACTIVATE WINDOW DefinedWindow && IN Window TopLevelFormREAD EVENTS _screen .Visible = .T. && Show ScreenDEFINE CLASS TopForm as FormShowWindow = 2 Name = "TopLevelForm" Caption = "Top Level Form" PROCEDURE DestroyCLEAR EVENTS ENDPROC ENDDEFINE |
Is there a particular reason you want to use define window? Forms are also windows and with VFP it's easier to work with forms. You could do this at runtime:
[code]
text to m.myScript noshow
oForm = createobject('myForm')
oForm.Show
define class myForm as Form
AlwaysOnTop = .t.
ShowWindow = 1 && In Top level
enddefine
endtext
ExecScript(m.myScript)
[/code]
define window mywindow from 18,8 to 30,94 title 'My File' FLOAT
SET EXACT OFF
SELECT myTable
SET ORDER TO TAG Descript
GO TOP
IF SEEK(alltrim(lcdescription))
activate window mywindow
on key label enter RELEASE window mywindow
BROWS FIELD Id=myTable.rec_numb, Particular=myTable.Description key ALLTRIM(lcdescription) NOED NOAPP NODEL in window myWindow
endif
RELEASE wind mywindow
I try that way but I do not know how to manipulate a certain record on it, myCursor will not disappear when I press the ENTER Key.
can you give me a code using cursor instead of window to manipulate a certain record, I will appreciate that very much.
What you do to show that record in a form's control (textboxes, etc) is assign the record field to control.value.
Ex:
ThisForm.txtCustomerName.Value = MyCursor.CustomerName
ThisForm.txtCity.Value = MyCursor.City
ThisForm.Refresh()
How could we do that in a cursor? and what is the code to release the cursor after you select a certain record on it? Because I try to use the cursor like example SELECT mytable.address FROM myaddress WHERE address = lcaddress order by address INTO cursor mycursor then brows....what next, i can only brows the records.
What I want is to select a record on it then press enter then release the cursor, then all the data pertaining the record selected will be transfered at my form's control.
Thank you and more power.
"Transfer to your form" - it depends. If you call a form that uses the same datasession as calling form does all you need is to position the record pointer ( by any means, it might be a browse, grid, listbox, combobox .... ). Your form then simply uses CursorName.FieldName to bind or refer to fileds of that cursor/table.
Here is a sample.
[code]
public oForm
oForm = createobject("CustomerSampleForm")
oForm.Show
define class CustomerSampleForm as Form
ShowWindow = 2 && As top level
Add object txtCustID as TextBox with controlsource = 'Customer.Cust_id'
Add object cmdGetCust as CommandButton with caption = 'Get Customer'
procedure load
use customer
endproc
procedure cmdGetCust.Click
* Create a modal form with a grid on it to locate a customer
text to memvar m.lcMyScript noshow
local loLocatorForm
loLocatorForm = createobject('LocatorForm')
loLocatorForm.Show
define class LocatorForm as form
ShowWindow = 1 && In top level
WindowType = 1 && Modal
add object myGrid as Grid with ReadOnly=.t., RecordSource = 'customer'
endtext
* Show the form with grid on it
ExecScript(m.lcMyScript)
thisform.refresh
endproc
enddefine
[/code]
If the called form needed to close cursor/table or in a different datasession then you simply return something so caller could locate the record itself. ie:
Called form might return:
-The primary key of record
-Record number of record
-Scatter to name oRecord and return it
Called form
-Directly get caller form as a reference and locate record in caller, set values, refresh it etc
You might download Foxyclasses sample from www.foxyclasses.com and check LocatorGrid samples. One of them almost exactly does what you describe and uses a grid on a form.
Thank you for the sample of yours, and thank you for giving me that foxy website. It's a nice website too.