do form testForm do form testForm with "Hello" do form testForm with "Hello",1 do form testForm with "Hello",1,date()-All work, right? OK it shows that form's init gets the parameters
lparameters p1,p2,p3 this.AddProperty('PassedParameter1', m.p1) this.AddProperty('PassedParameter2', m.p2) this.AddProperty('PassedParameter3', m.p3)* button click code edited
text to m.lcPassedParameters textmerge noshow Passed Parameter #1 is: <<thisform.PassedParameter1>> Passed Parameter #2 is: <<thisform.PassedParameter2>> Passed Parameter #3 is: <<thisform.PassedParameter3>> endtext MessageBox(m.lcPassedParameters)-Save and test again. Clicking the button now show your passed parameters. right? Great.
Public oForm oForm = Createobject('ContactsForm') oForm.Show Define Class ContactsForm As Form Width = 700 Height = 400 DataSession = 2 Add Object myGrid As Grid With ; width=700,Height = 300, DeleteMark=.F.,RecordMark=.F.,SplitBar=.F. Add Object someTextBox As TextBox With Top = 310, Width = 200 Procedure Init With This.myGrid .RecordSourceType = 4 .RecordSource = "select * from customer into cursor myCursor" For ix=1 To .ColumnCount With .Columns(m.ix) .AddObject('myTextBox','myTextBox') .CurrentControl = 'myTextBox' .Sparse = .F. .myTextBox.Visible = .T. Endwith Endfor .AddProperty('nCurrec',0) .AddProperty('InGrid') .SetAll('DynamicBackColor','(Iif(Recno()=this.nCurrec,0x00FFFF,0xFFFFFF))') Endwith Endproc Procedure myGrid.BeforeRowColChange Lparameters nColIndex Thisform.LockScreen = This.InGrid Endproc Procedure myGrid.AfterRowColChange Lparameters nColIndex This.nCurrec = Recno() Thisform.LockScreen = .F. Endproc Procedure myGrid.DblClick This.InGrid = .F. Thisform.LockScreen = .F. Thisform.CallChangeForm() Endproc Procedure myGrid.When This.InGrid = .T. Endproc Procedure CallChangeForm Thisform.LockScreen = .F. Local loForm,ix,jx,lcReturnMessage,luSomeCustomProperty,loParamCargo * Another parameter exchange tip loParamCargo = Createobject('custom') && 'Empty' class in VFP9 With loParamCargo .AddProperty('StartDate',{^1993/1/1}) .AddProperty('EndDate',{^1993/12/31}) .AddProperty('ProductList[1]') .AddProperty('Products') Select product_id ; from products ; where prod_name = 'C' ; into Array .ProductList Endwith * Another parameter exchange tip *DO form ChangeForm name loForm with Customer.Cust_ID, thisform, loParamCargo loForm = Createobject('ChangeForm',myCursor.Cust_id,Thisform,loParamCargo) loForm.Show * * Called form is a modal form * This part of code 'waits' called form to hide,release * to continue. Note that its exit button hide()s the form * so it's still there and we can interact This.someTextBox.Value = 'Returned from called form' lcReturnMessage = loForm.Tag luSomeCustomProperty = loForm.SomeCustomProperty loParamCargo = loForm.oParamCargo && Get processed one back loForm.Release() && Done with it-release Release loForm Messagebox(m.lcReturnMessage,0,'Called form Tag') Messagebox(m.luSomeCustomProperty,0,'Called form SomeCustomProperty') * loParamCargo return value Local lcText With loParamCargo Set Textmerge To Memvar m.lcText Noshow Set Textmerge On \\Product sales to customer between <<.StartDate>> and <<.EndDate>>: If .products = 0 \None. Else For ix=1 To .products For jx=1 To Amembers(aMemberProps,.ProductList[m.ix]) \<<aMemberProps[m.jx]>>: <<Evaluate('.ProductList[m.ix].'+aMemberProps[m.jx])>> Endfor Endfor Endif Set Textmerge To Set Textmerge Off Messagebox(m.lcText,0,'Called form ParamCargo') Endwith Endproc Enddefine Define Class myTextBox As TextBox Margin = 0 SpecialEffect = 1 BorderStyle = 0 Procedure DblClick This.Parent.Parent.DblClick() Endproc Enddefine Define Class ChangeForm As Form Top = 200 Left = 200 DataSession = 2 WindowType = 1 ControlBox=.F. Caption = 'Changes will not be saved' SomeCustomProperty = Datetime() oCaller = Null && reference to caller form Add Object txtCompany As TextBox With ; top=0, ControlSource='customer.Company' Add Object txtContact As TextBox With ; top=30, ControlSource='customer.Contact' Add Object txtCountry As TextBox With ; top=60, ControlSource='customer.Country' Add Object exitButton As CommandButton With ; top = 100, Caption='Done' Add Object toggleButton As CommandButton With ; top = 100, Left = 100, Caption='Hide Caller' Procedure Load Set Multilocks On Use Customer CursorSetProp("Buffering",5,'Customer') Endproc Procedure Init Lparameters tcCustomerID, toCallerForm, toParamCargo This.oCaller = toCallerForm Select Customer Locate For Upper(Cust_id) = m.tcCustomerID This.oCaller.someTextBox.Value = "Got parameters sir." If Type('toParamCargo') = 'O' This.AddProperty('oParamCargo',toParamCargo) This.ProcessParamCargo() Endif Endproc Procedure exitButton.Click TEXT to thisform.Tag textmerge noshow Edited customer values: Customer Id: <<customer.cust_id>> Company: <<customer.company>> Contact: <<customer.contact>> Country: <<customer.country>> ENDTEXT Thisform.oCaller.Visible = .T. && In case toggled Thisform.Hide() Endproc Procedure toggleButton.Click With Thisform If Type('.oCaller')='O' And ; !Isnull(.oCaller) And ; Lower(.oCaller.BaseClass) == 'form' If This.Caption = 'Hide Caller' .oCaller.Visible = .F. This.Caption = 'Show Caller' Else .oCaller.Visible = .T. This.Caption = 'Hide Caller' Endif Endif Endwith Endproc Procedure ProcessParamCargo Create Cursor ProductList (productID i) Append From Array Thisform.oParamCargo.ProductList With Thisform.oParamCargo Select ; o.Order_id, o.Shipped_on,; p.product_id, p.prod_name, oi.Quantity ; from orders o ; inner Join orditems oi On o.Order_id = oi.Order_id ; inner Join products p On oi.product_id = p.product_id ; inner Join ProductList pl On Val(p.product_id) = pl.productID ; where o.Cust_id == Customer.Cust_id And ; o.Shipped_on Between .StartDate And .EndDate ; into Cursor crsSold ; nofilter .products = _Tally If .products > 0 Dimension .ProductList[.Products] Scan Scatter Name .ProductList[Recno()] Endscan Endif Endwith Endproc EnddefineCetin