Category : C Source Code
Archive   : TCU_31.ZIP
Filename : BUTTON.C

 
Output of file : BUTTON.C contained in archive : TCU_31.ZIP
#include
#include
#include
#include "..\include\tcu.h"


void main (void)
{
int esc_key,
x_pos,
y_pos;
FORM form;
FORM_INFO info;
int far button_handler (FORM *, int);

/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

if (load_form (&form, "button") == TCU_ERROR) { /* Load the form from */
printf ("Error opening form file\n"); /* the CFO file */
exit (1);
}

get_form_info (&form, &info); /* Calculate where to put the */
x_pos = (80-info.width)/2+1; /* form to get it in the middle */
y_pos = (25-info.height)/2+1; /* of the screen */

set_button_fn (&form, button_handler); /* Set up the button handler */

display_form (&form, x_pos, y_pos); /* Get form on screen */

/* For this one we only want to accept button selections, so we keep */
/* looping around 'edit_form' until we get one. Using 0 as the start */
/* field keeps the field focus on the last selected field. This way */
/* the form stays exactly as it was until one of the buttons has been */
/* selected. */

do {
edit_form (&form, 0, &esc_key);
if (esc_key == FLD_BUTTONESC)
if (!get_confirm (25, 10, colour_attrib (WHITE, RED),
colour_attrib (WHITE, RED),
"QUIT: Are you sure? (Y/N)"))
esc_key = FLD_ESCESC;
} while (esc_key != FLD_BUTTONESC && esc_key != FLD_BUTTONSAVE);

remove_form (&form); /* Remove the form from the screen */
unload_form (&form); /* ...and from memory */

if (esc_key == FLD_BUTTONESC) /* Show which button was selected */
printf ("QUIT selected\n");
else
printf ("ACCEPT selected\n");
}


int far button_handler (FORM *form, int field)
{
if (field == get_field_id (form, "quit", NULL)) /* Is it QUIT button? */
return (2); /* Return saying ESCape form */
else
return (1); /* Otherwise, save & escape */
}


  3 Responses to “Category : C Source Code
Archive   : TCU_31.ZIP
Filename : BUTTON.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/