Re: Using callback to call other forms

Robert J. Nield (ceerjn@cee.hw.ac.uk)
Thu, 6 Feb 1997 23:22:02 +0000 (GMT)

To subscribers of the xforms list from "Robert J. Nield" <ceerjn@cee.hw.ac.uk> :

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Robert J.Nield ~
~ -------------- ~
~ Telephone / answer machine: +44(0)131 449-8323 ~
~ Home page at http://www.cee.hw.ac.uk/~ceerjn ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

On Wed, 5 Feb 1997, Donald Epand wrote:

> To subscribers of the xforms list from Donald Epand <depand@phx.cox.com> :
>
> Hello,
> I am trying to create an application where a main form contains buttons
> which call up other forms. I have created the main form with a button
> say paddle. Then I created another form paddle. I call paddle from the
> main form using the paddle button on the main form. I am getting errors
> when I try to do this. What is the correct way to accomplish what I am
> trying to do.?
> Don
> ---------------------------------------------------------------
( this is how I ws told how to do it !)

Well, first you must make the pointer to the form global in the x_main..c
i.e.

FD_formname *fd_formname;

This allows you to reference the form outwith the main prog.

Now in your x_cb.c ( which is your callback file ) you must enter in the
code which actually fires up the screen. The code below opens the form on
one click and then closes it on the second.

void main_history(FL_OBJECT *ob, long data)
{
static int IsWindowOpen = 0;

if ( IsWindowOpen == 1 )
{
fl_hide_form( fd_history_yn->history_yn );
IsWindowOpen = 0;
}

else
{

fl_show_form(fd_history_yn->history_yn,FL_PLACE_CENTER,FL_FULLBORDER,"History");
IsWindowOpen = 1;

}
}

Right. the main parts to that were first 'showing' the form on the first
click then 'hiding' the form on the second.

But basically, you can just use

fl_show_form(fd_formname->formname,FL_PLACE_CENTER,FL_FULLBORDER,"nameof form")

So now you have your code yo call your form from your callback file, make
sure all of your include files are okay.

Last bit, not sure if needed as I cannot remember whether I put this in
when I was having a bit of a hack, but it looks logical...
So after the 'fl_do_forms();' line
put:-

fl_free( fd_formname->formname );
free( fd_formname );

Hope its okay.

Rob.

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/xforms-archive/