In the Designer, if you specify a sub-form in the "Basic Menu Field Information" dialog box, the stub function created by the Main Generator will include code to get the form from the library, process it, and then free it. You can then modify the stub function to add whatever processing you desire.
You can also get a pointer to the form name from the menu field structure itself, with the menu field sub-form name function, mnf_subfmnam():
|
This function takes a pointer to the menu field, and returns a pointer to the sub-form name. For more information about how to get a pointer to a field, see Chapter 34, "Getting and Updating Data in the Form."
You can determine whether the sub-form or sub-menu is in memory by calling the form name pointer function, :
|
This function takes a pointer to the form name. If a form by that name is in memory, it returns a pointer to that form; if no form by that name exists, it returns NULLP. If there is more than one form with this name in memory, it returns a pointer to the most recently defined form.
It is important to check whether the form is already in memory, to avoid having two or more copies of the form in memory at once.
If the form is not currently in memory, you must call dl_fmget() or dl_mnget() to read the form from the Designer library, or fm_def() or mn_def() to define the form, before processing it.
If this is a modal form, you may wish to free the form before returning from the action function. If you do not free the form in your action function, it is your responsibility to free it later.
If this is a non-modal form, freeing the form in the action function causes an error. You can use the window option AUTOFREE to have Vermont Views free the form automatically, or you can free it at some other point in your code. For more information on non-modal programming, see Chapter 30, "Differences in Non-Modal Form Processing."