Window dialog boxes The modal form Menus
Programming guideline of WinDom

Binded objects

From the version fev 2000 of WinDom, there is a new - a third - way to handle forms in windows: it is possible to bind an object of a form to a variable or a function with the ObjcAttach() function.

Bind to a variable :

The idea is to link a selectable object to a variable: when the user selects or unselects this object, the variable binded is automatically updated. There are two cases :

Bind to a function:

If the simple SELECTABLE objects represent the value of a variable, the EXIT or TOUCHEXIT objects often require a complex operation. For example, the OK button closes the form or the SAVE button save the parameters. For that purpose, these objects may be linked to a function. If the user selects these objects, the binded function is invoked. Thus, it is not neccessary to write a WM_FORM event function to handle a form. Example :


	/* This function unselected the selected objet and
     * close the window. A binded object function has the
     * following prototype:
     * void Func( WINDOW *win,		// window descriptor
     *            int   index,		// index of the selected object
     *            int    type);		// OC_FORM or OC_TOOLBAR
     */

	void OkBut( WINDOW *win, int index, int type) {
		ObjcChange( type, win, index, NORMAL, 1);
		ApplWrite( app.id, WM_CLOSED, win->handle);
	}

	ObjcAttach( OC_FORM, win, OK_BUT, BIND_FUNC, OkBut);