home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c003 / 1.ddi / DEMOS / TUT_HELP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1987-02-02  |  1.5 KB  |  47 lines

  1. /*tut_help.c -- displaying and scrolling a help file
  2.  
  3.   ************* (C) Copyright Vermont Creative Software 1985 ***************
  4.  
  5. */
  6.  
  7. #define HELPFILE "help.txt"
  8. #define HELPKEY -K_F1            /*"extended keys" return negative code*/
  9. #define EXIT -K_F10
  10. #define MAXCOL 76            /*window will have only 76 col for txt*/
  11. #define MAXLINES 200            /*the help file is < 200 lines          */
  12.  
  13. #define WN_DEBUG
  14. #include <wfc.h>
  15. #include <wfc_glob.h>
  16.  
  17. main()
  18. {
  19.     WINDOW hwn;
  20.     MFILEPTR mfhelp;                /*memory file for help file       */
  21.     int kc;                    /*key code                  */
  22.  
  23.     init_wfc();                 /*initialize program          */
  24.     cls();
  25.     mfhelp = mf_def(HELPFILE, MAXLINES, MAXCOL);  /*init. file record          */
  26.     defs_wn(&hwn, 16, 0, 9, 80, BDR_LNP);   /*define help window          */
  27.     sw_popup(ON, &hwn);             /*make a pop-up window          */
  28.     sw_att(LHELP, &hwn);            /*set attributes for help          */
  29.     sw_bdratt(LHELP, &hwn);
  30.     sw_mf(mfhelp, &hwn);            /*install pointer to mfhelp       */
  31.  
  32.     v_st("Press key F1 to toggle help window\n" ,&wn0);
  33.     v_st("When not in help window, press F10 to exit program.", &wn0);
  34.     while((kc = ki()) != EXIT)
  35.     {
  36.     if(kc == HELPKEY)            /*help requested              */
  37.     {
  38.          if(! mf_rd(mfhelp))        /*read in help file           */
  39.           errout("error reading file ", HELPFILE);
  40.          vs_mf(HELPKEY, &hwn);        /*turn over to viewer          */
  41.          mf_clr(mfhelp);
  42.     }
  43.     }
  44.     exit_wfc();
  45.     return(0);
  46. }
  47.