To create it, use FormCreate():
WINDOW *FormCreate( OBJECT *tree, int Widget, VOID *proc, GRECT *coord, int weffect, int dup);It is a huge function. As you can see, you have to give the address of an AES object tree (the form itself). First, the function verifies if the form is already created i.e. if a window form owns the same object tree. In this case the window is either reopened, uniconified or topped in foreground. It is possible to create several forms with the same object tree with the option dup set to 1. In this case the object tree is duplicated in memory (An object tree can be manually dupicated with the ObjcDup() function, the WS_FORMDUP flag of the window status - i.e. the win->status variable - should be set to 1 meanning that the duplicated object tree memory must be released by the window destroy function). Second, FormCreate() attaches standard event functions to the created window. These standard functions are devoted to form managing and seting some critical window variables.
2 form managing
Now the form is created and is displayed by your application. You have to analyze the result of the user interaction with your dialog box objects.
Example 1: using the main loop event
Here is a typical example, where we create a form (after a desktop menu selection), and then analyze the result:
/* The main loop event */ while(1) { EvntWindom( MU_MESAG); if( evnt.buff[0] == MN_SELECTED) { /* one selects an item int the desktop menu */ switch( evnt.buff[4]) { case MENU_ITEM_FORM1: /* Create the form */ rsrc_gaddr( 0, FORM1, &tree); FormCreate( tree, /* the object tree */ MOVER|NAME|SMALLER, /* window widgets */ NULL, /* no function result */ "Window title", NULL, /* The position of the form, if NULL, * the form will be centered, and the window size * computing according to the object root size */ 1, /* activate the graf_growbox effects */ 0); /* Don't duplicaterd the object tree */ break; .... } } if( evnt.buff[0] == WM_FORM) { /* this message means that the user has clicked an EXIT * or TOUCHEXIT object in a form */ WINDOW *form; int obj; form = WindHandle( evnt.buff[3]); /* Get the window descriptor of the form */ obj = evnt.buff[4]; /* index of the targetted object */ switch ( objc) { case BUT_OK: break; ... } ObjcChange( OC_FORM, win, objc, NORMAL, 1); /* set the object state to NORMAL */ } }Example 2: using an event function
The second part of the previous example can be placed in an event function. The proc parameter of the FormCreate() function defines this function. When EvntWindom() receives an WM_FORM message, its executes directly this function. The event function have the folowing structure:
void DoForm( WINDOW *win ) { int objc = evnt.buff[4]; switch( objc) { case BUT_OK1: .... break; .... } ObjcChange( OC_FORM, win, objc, NORMAL, 1); }and the FormCreate() call is:
FormCreate( MOVER|NAME|SMALLER, tree, DoForm, "Window title", NULL, 1, 0);ObjcChange() is the WinDom equivalent of the AES objc_change() function.
Remark for expert:
If you want to create yourself a form without the FormCreate() function, we list the main important steps to respect: