Dynamically Adding Items to a Form

Items cannot be added to any form while it is initialized. This is because the array of items for the form is built when the form is initialized or made ready. The array cannot be changed dynamically.

The array of items is built the first time the form is displayed on the screen, or when you call fm_ready() for the form. It is not normally freed until the form itself is freed. However, you can call the function fm_unready() to free this array and other temporary storage space allocated when the form was initialized. fm_unready() can be called for data forms or menus. The call for fm_unready() is as follows:

int fm_unready(fmp)

FORMPTR fmp;            /*Pointer to data form or menu            */

After calling fm_unready(), you can add items to the form by calling the appropriate function: fld_def(), mnf_def(), pb_def(), etc. When you put the form back on the screen, or when you call fm_ready() for the form, the item array and other temporary storage space will be reallocated.

If you want to add items to a form dynamically, then, you must follow these steps:

Caution: When you call fm_unready() for a data form, the current contents of the field edit buffers are lost. If the form is currently being processed, the information that the user has typed into the form will be lost. If you need to retain that information, you can call fm_convert() to convert the current contents of the fields and update the underlying data variables before calling fm_unready().

Designer Forms: A Designer form is automatically made ready when it is read from the Designer library. To add items dynamically to a Designer form, you must read the form from the library, call fm_unready(), add the items, and call fm_ready().


Home Contents Previous Next