⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 boss.man

📁 BOSS窗口开发 C 语言程序库
💻 MAN
📖 第 1 页 / 共 5 页
字号:

        /* End */










                                                           Page: 5
                                                     The Window BOSS



        4.2. Data Entry Basics

        Lets expand our "hello" program to prompt and fetch a name.

        #include "windows.h"            /* REQUIRED */
        main()
        {
        WINDOWPTR w1;                   /* window handle */
        int batrib;                     /* border atrib */
        int watrib;                     /* window atrib */
        char name[15];                  /* name */

        /*
         * Set attributes:
         *
         *      border - blue/white box
         *      window - white background/black letters
         *
        */

          batrib = (BLUE << 4) | WHITE; /* border atrib */
          watrib = (WHITE <<4) | BLACK; /* window atrib */

        /*
         * Open window at 0,0 - 25 cells wide and 10 cells high
        */

          w1 = wn_open(0,0,0,25,10,watrib,batrib);
          if(!w1) exit();       

        /*
         * Print the famous string, prompt and fetch a name, 
         * wait for key to be struck.
         * Close window on key strike.. exit.
        */

          wn_printf(w1,"Hello World...");

          *name = NUL;                  /* init buffer for name */
          wn_gtext(XEQ,NFRM,NFLD,w1,2,1,"Name: ",watrib,'_',15,name,NSTR,NSTR);

          v_getch();                    /* wait for key */
          wn_close(w1);                 /* close the window */
          exit(0);                      /* and exit */
        }

        /* End */









                                                           Page: 6
                                                     The Window BOSS



        4.3. Form Basics

        Now we will expand a bit further to read a 2 field form.

        #include "windows.h"            /* REQUIRED */
        main()
        {
        WINDOWPTR w1;                   /* window handle */
        WIFORM f1;                      /* form handle */
        int batrib;                     /* border atrib */
        int watrib;                     /* window atrib */
        char name[15];                  /* name */
        char city[15];                  /* city */

        /*
         * Set attributes:
         *
         *      border - blue/white box
         *      window - white background/black letters
         *
        */

          batrib = (BLUE << 4) | WHITE; /* border atrib */
          watrib = (WHITE <<4) | BLACK; /* window atrib */

        /*
         * Open window at 0,0 - 25 cells wide and 10 cells high
        */

          w1 = wn_open(0,0,0,25,10,watrib,batrib);
          if(!w1) exit();       

        /*
         * Print the famous string, create, define, and fetch form
         * wait for key to be struck.
         * Close window on key strike.. exit.
        */

          wn_printf(w1,"Hello World...");

          *name = NUL;                  /* init buffer for name */
          *city = NUL;                  /* init buffer for city */
          f1 = wn_frmopn(3);            /* open form 2 + 1 Fields */
          wn_gtext(SET,f1,0,w1,2,1,"Name: ",watrib,'_',15,name,NSTR,NSTR);
          wn_gtext(SET,f1,1,w1,3,1,"City: ",watrib,'_',15,city,NSTR,NSTR);
          wn_frmget(f1);                /* read the form */

          v_getch();                    /* wait for key */
          wn_frmcls(f1);                /* first close the form */
          wn_close(w1);                 /* then close the window */
          exit(0);                      /* and exit */
        }




                                                           Page: 7
                                                     The Window BOSS



        4.4. Popup Menu Basics

        Popup and pulldown menus add that extra sparkle to your 
        applications.  The Window BOSS includes a simple popup menu 
        system that is fast and easy to use.  The system consists of two 
        functions; wn_popup() and wn_qpopup().  wn_popup() is an 
        interactive version of wn_qpopup().  That is to say that 
        wn_popup() can be used to solicit user input while wn_qpopup is a 
        *information only* popup.  The "q" in qpopup stands for 'quick'.  
        Both functions have function parameters and require the menu 
        structure "pmenu" to be initialized.  "pmenu" is defined in 
        "windows.h".

        Popup menus, like windows, have size (height & width), an origin 
        (row & column), and attributes (text & border).  These are passed 
        as parameters to both wn_popup and wn_qpopup in the same fashion 
        as they would be for a call to wn_open.  In addition to the 
        normal window stuff, popup menus also have information that needs 
        to be displayed and, in some cases, information that needs to be 
        returned, to the calling function.  This additional information 
        is passed to popup via the pmenu structure.  The pmenu structure 
        allows us to tell wn_popup what text is to be displayed where, 
        and what value (return code), if any, is to be provided back to 
        the calling function.

        Both wn_popup and wn_qpopup call wn_open to open a window defined 
        by the calling parameters. Calls to wn_putsa are then made to 
        display the text defined in pmenu within the window just opened 
        at the location in the window specified by the values defined in 
        pmenu.  A menu item is highlighted by moving either the cursor 
        keys, space bar, or by pressing the first character of the menu 
        item desired.  Control is passed back to the calling function 
        when the 'Enter' or 'Escape' key is pressed. Here is a typical 
        call to wn_popup:

            wat = (WHITE<<4|BLACK);
            bat = (BLUE<<4|WHITE); 
            rv = wn_popup(0, 0, 0, 33, 14, wat, bat, &intelc, FALSE);
                          |                       |  |     |  |   |
                          +-------\/--------------+  |     |  |   |
                             Normal wn_open parms    |     |  |   |
                                                     |     |  |   |
                                  pmenu structure  <-+-----+  |   |
                                                              |   |
                                        window close flag   <-+---+

        The normal wn_open parameters define the popup menu's location, 
        size, and color.  The pmenu structure address allows wn_popup and 
        wn_qpopup to access the contents of the intelc pmenu structure.  
        The window close flag is used to tell wn_popup whether or not to 
        close the popup menu when returning to the calling function. 
        Telling wn_popup to not to close the menu when returning to the 
        calling function allows you to create nested popups.



                                                           Page: 8
                                                     The Window BOSS



        Popup Menu Basics - continued.



        Lets examine the pmenu structure definition from windows.h:

          struct mitem {              /* POPUP menu item template */
            int r;                    /* row */
            int c;                    /* col */
            char *t;                  /* text */
            int rv;                   /* return value */
          };

          struct pmenu {              /* POPUP menu structure */
            WINDOWPTR wpsave;         /* place to hold window id */
            int winopn;               /* leave window open flag */
            int lndx;                 /* last index */
            int fm;                   /* first menu item index */
            int lm;                   /* last menu item index */
            struct mitem scrn[WN_MXROWS*4]; /* a bunch of menu items */
          };                          /* NOTE RELATIVE LIMIT */

          mitem - Popup menus contain a number of menu items. Each menu 
          item has a location (within the window), text (to be displayed 
          in the window), and an integer return code that is passed back 
          to the calling function to let the caller know which menu item 
          was selected.  "r" and "c" define the row and column, "t" is a 
          pointer to the text, and rv is integer return code.
             
          pmenu - In addition to the information needed about each menu 
          item, we need to do some internal housekeeping on the popup 
          menu itself.  "wpsave" is used to store the WINDOWPTR that was 
          returned from the call to wn_open made by popup. "winopn" is 
          used internally by popup as an indicator of whether or not the 
          window referenced by wpsave is currently open.  "lndx" is used 
          internally to hold the index of the menu item last referenced 
          or selected.  The combination of "wpsave", "winopn", and "lndx" 
          provide wn_popup with the ability to correctly handle both 
          nested and non-nested popups.  The structure members "wpsave", 
          "winopn", "lndx" should not be modified, only initialized. 
















                                                           Page: 9
                                                     The Window BOSS



        Popup Menu Basics - continued.



          The Window BOSS's popup menus allow you to have informational 
          headers and trailers.  This is handy for providing multiple 
          line titles and or trailing instructional messages.  Consider 
          the following:

             +---------------------------------+
             |                                 |
             |           Intellicom            |   <- Informational
             |          Quick - Help           |   <- Informational
             |                                 |
             |     1 General Information       |   <- Action item
             |     2 Terminal Mode Options     |   <- Action item
             |     3 XMODEM File Send          |   <- Action item
             |     4 XMODEM File Receive       |   <- Action item
             |     5 CompuServe Exec Mode      |   <- Action item  
             |                                 |
             |  Press: ESC to quit or Cursor   |   <- Informational
             |   Keys to Position Cursor then  |   <- Informational 
             |   press RETURN for MORE info.   |   <- Informational
             |                                 |
             +---------------------------------+

          In the above popup there are 10 menu items, 5 are action 
          oriented, and 5 are informational.  They are numbered 0 through 
          9 and correspond to the "scrn" array of pointers in the pmenu 
          structure. "fm" and "lm" are the indexes of the first and last 
          action items in scrn array.  In the case of the above popup, fm 
          and lm would be initialized to 2 and 6 respectively. "fm" and 
          "lm", like the other housekeeping structure members should not 
          be modified only initialized.  The pmenu structure for this 
          popup is as follows: 

          static struct pmenu intelc = {
            0, FALSE, 0,                     /* wpsave, winopn, lndx */
             2, 6, {                         /* fm, lm */
             1, 2, "         Intellicom", 0,            /** ----- **/
             2, 2, "        Quick - Help", 0,           /*    |    */ 
             4, 5, "1 General Information  ", 1,        /*    |    */
             5, 5, "2 Terminal Mode Options", 2,        /*    |    */
             6, 5, "3 XMODEM File Send     ", 3,        /* 10 menu */
             7, 5, "4 XMODEM File Receive  ", 4,        /*  items  */
             8, 5, "5 CompuServe Exec Mode ", 5,        /*         */
            10, 2, "Press: ESC to quit or Cursor", 0,   /*         */
            11, 2, " Keys to Position Cursor then", 0,  /*         */
            12, 2, " press RETURN for MORE info.", 0,   /** ----- **/
            99, 99, "",99 }                 /* ALWAYS ADD THIS LINE */
          };
          




                                                           Page: 10
                                                     The Window BOSS



        Popup Menu Basics - continued.



        The end of the pmenu structure is designated by defining a menu 
        item at row 99, column 99, with null text, with a return code of 
        99.  THIS MUST ALWAYS BE DONE!

          Example:
             
             #include "windows.h"

             static struct pmenu intelc = {
               0, FALSE, 0,
               2, 6, {
               1, 2, "         Intellicom", 0,
               2, 2, "        Quick - Help", 0,
               4, 5, "1 General Information  ", 1,
               5, 5, "2 Terminal Mode Options", 2,
               6, 5, "3 XMODEM File Send     ", 3,
               7, 5, "4 XMODEM File Receive  ", 4,
               8, 5, "5 CompuServe Exec Mode ", 5,
              10, 2, "Press: ESC to quit or Cursor", 0,
              11, 2, " Keys to Position Cursor then", 0,
              12, 2, " press RETURN for MORE info.", 0,
              99, 99, "",99 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -