>For us to assist you further, you may post the main portion of your main program. I want to see the structure of it for me assess how you called and instantiated those form and toolbar controls. Another thing, do you have a menu?
This is the order of events to call and to release the edit form.
I really appreciate your assistance!
*-- The main program instantiates the application control
*-- and runs runapp():
PRIVATE poAppContr
poAppContr=NEWOBJECT("AppContr","AppContr")
poAppContr.RunApp()
READ EVENTS
*-- Run app instantiates the form handler that is
*-- referenced in a property of the AppContr.:
THIS.FrmHandl = NEWOBJ("FrmHandl","AppContr")
*-- Then the application screen is made visible (all forms are top level
*-- screens.
THIS.oMainScreen = NEWOBJECT("MainForm","Applic")
THIS.oMainScreen.VISIBLE = .T.
*-- From this form you can call an edit form like so:
*-- oMainScreen.EditEntry(), create a data object:
SELECT MyTable
SCATTER NAME oDataObject
*-- Instantiate and show the edit screen.
poAppContr.FrmHandl.GetFormHandle(oDataObject)
*-- The code in the form handler is like so:
LPARAMETER toDataObject
=ACOPY(THIS.aForms, laFormArray)
laFormArray[lnNewElement,1] = NEWOBJ("frmEditPhone","Applic","",toDataObject)
*-- I also store the data id (oDataObject.CId is the records unique number)
*-- so I can find this form without problems again.
laFormArray[lnNewElement,2] = toDataObject.CId
WITH laFormArray[lnNewElement,1]
.VISIBLE = .T.
ENDWITH
=ACOPY(laFormArray, .aForms)
*-- In the edit form I do the following:
*-- In the init get the data object and set controlsource etc.
LPARAMETER toData
THIS.oData = toData
THIS.txtName.CONTROLSOURCE = "THISFORM.oData.CName"
*-- And display the menu.
DO EditFormMenu.PRG WITH THIS,.T.
*-- In activate instantiate the toolbar.
THIS.oToolBar = NEWOBJ("MyToolbar","Toolbar","",THIS)
THIS.oToolBar.VISIBLE=.T.
*-- To close the form, I would call the ReleaseThisForm method
*-- in the form handler:
LPARAMETER tnFormId
lnThisForm = ASCAN(THIS.aForms,tnFormId)/2
IF lnThisForm > 0
IF VARTYPE(THIS.aForms[lnThisForm,1]) = "O"
THIS.aForms[lnThisForm,1].RELEASE()
ENDIF
THIS.aForms[lnThisForm,1] = NULL
THIS.aForms[lnThisForm,2] = NULL
ENDIF
This works very good from any button on the form or from the menu on the form.
Because it is possible that the user presses the X button on the form,
I call the ReleaseThisForm method also from the Destroy event.
When I RELEASE the form from within the toolbar, or when I call the ReleaseThisForm
method from the toolbar, the form doesn't release from memory.
Christian Isberner
Software Consultant