>>>IIRC, that is more or less the way the Visual Extend framework handles it - an array of forms, in the global applicatoin object. Of course, being a good framework, this is done so far in the background, and so transparently, that I usually don't have to check how it's done.
>>>
>>>>You can have an array property in your form manager class and have this array property hold a reference to each open form. When you done with the form, you should set this array element to NULL.
>>>>
>>>>That's an idea, I need to check on Monday at work how do I manage this problem in my form's manager class.
>>
>>
>>Maybe something like this:
>>
>>PROCEDURE Init
>> This.AddToFormsCollection
>>ENDPROC
>>PROCEDURE Destroy
>> This.RemoveFromFormsCollection
>>ENDPROC
>>*
>>** Add to Forms Collection (inorder to stay alive)
>>*
>>PROCEDURE AddToFormsCollection
>>IF TYPE("_screen.FormsCollection") = 'O'
>> _screen.FormsCollection.Add(THIS)
>>ENDIF
>>ENDPROC
>>*
>>** Remove from Forms Collection (inorder to be allowed to die)
>>*
>>PROCEDURE RemoveFromFormsCollection
>>LOCAL lIndex
>> FOR lIndex = 1 TO _Screen.FormsCollection.Count
>> IF _Screen.FormsCollection.Item(lIndex) = THIS
>> _Screen.FormsCollection.Remove(lIndex)
>> EXIT
>> ENDIF
>> ENDFOR
>>ENDPROC
>
>Yes, that would be one way. However, the way VFX works, IIRC, is a little different. Instead of
do form, the user is expected to do something like
goProgram.RunForm(). I am not sure about the method name right now, but goProgram is the application object. The method will add the form to the form collection in the application object.
>
>Most of the time, I don't call this method explicitly: I just add the form to a table of available forms, and Visual Extend takes care of the rest (i.e., when the user selects "File | Open", he will see a list of available forms, depending on his access level).
I forgot to add, the application object or main form has to do this:
_Screen.AddProperty("FormsCollection","")
_Screen.FormsCollection = CREATEOBJECT("collection")
and you call the form this way:
DO "formname.prg"
I just recently started trying out Class-based forms and got this from "Build Your Own Framework" by Kenneth Chazotte.
I also add the form to the "available commands" table in our "DynamicMenu" database and only authorized users will see it in their menu.