home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / DATABASE / DBT123S.ZIP / CLOSET.PRG < prev    next >
Text File  |  1990-07-23  |  10KB  |  247 lines

  1. *   CLOSET.PRG - Skeletons in my closet
  2. *                Skeleton code for pulldown menu system
  3. *   (c) 1990 BERNATH COMPUTER
  4. *   07/20/1990
  5.  
  6. *   This code segment acts as a skelton for you to "flesh out" to produce
  7. *   your own pulldown menu system. You'll need to change the menu item
  8. *   text, colors, coordinates, the number of menu items, routines to call,
  9. *   etc, as desired.
  10. *   This code segment will not execute as shown, but acts as a guide.
  11.  
  12.  
  13.  
  14. mNUMHORZ=4                              && put # of horizontal menu items here
  15. EXITNOW=.F.
  16. HCHOICE=1
  17. VCHOICE=0
  18. mHKPROC="HKMAIN"                        && name of hotkey processor
  19.  
  20. DO WHILE .NOT. EXITNOW
  21.     DO DRAWBG                           && a routine to create a backdrop. See below
  22.     VCHOICE=0
  23.     mMENUSTR="9,Y,"+STR(HCHOICE,2)+",1,2,14,1,15,0,  1. HMENU option 1  ,  2. HMENU option 2  ,  3. HMENU option 3  ,    QUIT    ,@"
  24.     CALL DBTOOLS WITH mMENUSTR
  25.     HCHOICE=VAL(mMENUSTR)
  26.     DO CASE
  27.         CASE HCHOICE=1      && --------HMENU Option 1------------------
  28.             VCHOICE = 1
  29.             * Code for popup menu off of HMENU first option:
  30.             DO WHILE VCHOICE<>0
  31.                 CALL DBTOOLS WITH "21,13,2,5,6,20,1,7,1,1"
  32.                 mPARM="20,Y,"+STR(VCHOICE,2)+",13,15,0,2,First choice,Second choice,Third choice,@"                mPARM="20,Y,"+STR(VCHOICE,2)+",13,15,0,2,First choice,Second choice,Third choice,@"
  33.                 CALL DBTOOLS WITH mPARM
  34.                 VCHOICE=VAL(mPARM)
  35.                 DO CASE
  36.                     CASE VCHOICE=1
  37.                         * Put DO <?> program to call when option 1 selected
  38.                     CASE VCHOICE=2
  39.                         * DO <option 2 program>
  40.                     CASE VCHOICE=3
  41.                         * DO <option 3 program>
  42.                     CASE VCHOICE=99
  43.                         * hotkey and control key processing
  44.                         DO TRAPIT WITH mPARM,HCHOICE,mNUMHORZ,"HKMAIN"               ENDCASE
  45.                         EXIT
  46.                 ENDCASE
  47.                 CALL DBTOOLS WITH "19,13"       && unpop window
  48.             ENDDO
  49.  
  50.         CASE HCHOICE=2         && -------HMENU Option 2-------------------
  51.  
  52.             * Code for popup menu off of HMENU second option:
  53.             DO WHILE VCHOICE<>0
  54.                 CALL DBTOOLS WITH "21,13,2,29,7,44,1,7,15,0,1,1"
  55.                 mPARM="20,Y,"+STR(VCHOICE,2)+",13,15,0,2,First choice,Second choice,Third choice,Fourth choice,@"
  56.                 mPARM="20,Y,"+STR(VCHOICE,2)+",13,
  57.                 CALL DBTOOLS WITH mPARM
  58.                 VCHOICE=VAL(mPARM)
  59.                 DO CASE
  60.                     CASE VCHOICE=1
  61.                         * Put DO <?> program to call when option 1 selected
  62.                     CASE VCHOICE=2
  63.                         * DO <option 2 program>
  64.                     CASE VCHOICE=3
  65.                         * DO <option 3 program>
  66.                     CASE VCHOICE=4
  67.                         * DO <option 4 program>
  68.                     CASE VCHOICE=99
  69.                         * hotkey and control key processing
  70.                         DO TRAPIT WITH mPARM,HCHOICE,mNUMHORZ,"HKMAIN"               ENDCASE
  71.                         EXIT
  72.                 ENDCASE
  73.                 CALL DBTOOLS WITH "19,13"       && unpop window
  74.             ENDDO
  75.         CASE HCHOICE=3         && -------HMENU Option 3---------------
  76.  
  77.             * Code for popup menu off of HMENU third option:
  78.             DO WHILE VCHOICE<>0
  79.                 CALL DBTOOLS WITH "21,13,2,49,6,64,1,7,15,0,1,1"
  80.                 mPARM="20,Y,"+STR(VCHOICE,2)+",13,15,0,2,First choice,Second choice,Third choice,@"
  81.                 CALL DBTOOLS WITH mPARM
  82.                 VCHOICE=VAL(mPARM)
  83.                 DO CASE
  84.                     CASE VCHOICE=0              && ESC pressed
  85.                     CASE VCHOICE=1
  86.                         * Put DO <?> program to call when option 1 selected
  87.                     CASE VCHOICE=2
  88.                         * DO <option 2 program>
  89.                     CASE VCHOICE=3
  90.                         * DO <option 3 program>
  91.                     CASE VCHOICE=99
  92.                         * hotkey and control key processing
  93.                         DO TRAPIT WITH mPARM,HCHOICE,mNUMHORZ,"HKMAIN"               ENDCASE
  94.                         EXIT
  95.                 ENDCASE
  96.                 CALL DBTOOLS WITH "19,13"       && unpop window
  97.             ENDDO
  98.         CASE HCHOICE=mNUMHORZ  && ----------Last HMENU choice-------------
  99.             CALL DBTOOLS WITH "21,13,3,65,6,76,7,4,1,1"
  100.             VCHOICE = 1
  101.             mPARM="20,Y,"+STR(VCHOICE,2)+",3,15,0,1,Main Menu,Dot Prompt,@"
  102.             CALL DBTOOLS WITH mPARM
  103.             VCHOICE = VAL(mPARM)
  104.             DO CASE
  105.                 CASE VCHOICE = 1
  106.                     EXITNOW = .T.
  107.                 CASE VCHOICE = 2
  108.                     CALL DBTOOLS WITH "19,13"
  109.                     CLEAR
  110.                     CANCEL
  111.                 CASE VCHOICE = 99
  112.                    DO TRAPIT WITH mPARM,HCHOICE,mNUMHORZ,"HKMAIN"
  113.             ENDCASE
  114.             CALL DBTOOLS WITH "19,13"
  115.  
  116.         CASE HCHOICE=99        && ----------HMENU hotkey processing-------
  117.             mKEY=ASC(SUBSTR(mMENUSTR,4,1))-1
  118.             mSCAN=ASC(SUBSTR(mMENUSTR,5,1))-1
  119.             HCHOICE=ASC(SUBSTR(mMENUSTR,6,1))
  120.             DO &mHKPROC WITH mKEY,mSCAN,HCHOICE
  121.     ENDCASE   && HMENU case
  122. ENDDO
  123. RETURN
  124.  
  125. * NOTES:
  126. *   When you call another .PRG file off of a VMENU option, use function 15
  127. *   to save the screen at the beginning of the program, and function 14 to
  128. *   restore the screen right before the RETURN.
  129. *
  130. *       OPTION.PRG
  131. *       CALL DBTOOLS WITH "15,3"        && save screen in slot 3
  132. *               .
  133. *          <program body>
  134. *               .
  135. *       CALL DBTOOLS WITH "14,3,0"      && restore screen
  136. *       RETURN                          && return to main menu
  137.  
  138.  
  139. *|===================================================================
  140. *|  PROCEDURES - you'll need to put these in a procedure file
  141. *|===================================================================
  142.  
  143.  
  144. * -------------------------------------------------------------------
  145. *   TRAPIT - extracts scancodes and processes keys for VMENU
  146. *   This code can remain as is.
  147. * -------------------------------------------------------------------
  148. PROCEDURE TRAPIT
  149. PARAMETERS mPARMSTR,HCHOICE,mMAXOPT,mHKPROC
  150.     mKEY=ASC(SUBSTR(mMENUSTR,4,1))-1
  151.     mSCAN=ASC(SUBSTR(mMENUSTR,5,1))-1
  152.     mCUROPT=ASC(SUBSTR(mMENUSTR,6,1))
  153.     mRETVAL = 0
  154.     DO CASE
  155.         CASE mKEY=0 .AND. mSCAN=75              && west
  156.             IF HCHOICE = 1
  157.                 mRETVAL = mMAXOPT
  158.             ELSE
  159.                 mRETVAL = HCHOICE - 1
  160.             ENDIF
  161.         CASE mKEY=0 .AND. mSCAN=77              && east
  162.             IF HCHOICE = mMAXOPT
  163.                 mRETVAL = mMAXOPT
  164.             ELSE
  165.                 mRETVAL = HCHOICE - 1
  166.             ENDIF
  167.         CASE mKEY=0 .AND. mSCAN=35              && Alt-h for Help
  168.             DO DISPHELP WITH HCHOICE,mCUROPT
  169.             mRETVAL = -HCHOICE
  170.         CASE mKEY=27 .AND. mSCAN=0              && ESC
  171.             mRETVAL = -HCHOICE                  && hotkey
  172.         OTHERWISE
  173.             DO &mHKPROC WITH mKEY,mSCAN,HCHOICE
  174.     ENDCASE
  175.     HCHOICE = -mRETVAL
  176. RETURN
  177.  
  178.  
  179. * ----------------------------------------------------------------
  180. *   HKMAIN - Hot key processor. You will have to change this to
  181. *   reflect your own choices.
  182. *   See Appendix E for scancodes for hotkeys.
  183. * ----------------------------------------------------------------
  184.  
  185. PROCEDURE HKMAIN
  186. PARAMETERS mKEY,mSCAN,HCHOICE
  187.     DO CASE
  188.        CASE mKEY=0 .AND. mSCAN=120              && Alt-1
  189.            mRETVAL = 1
  190.        CASE mKEY=0 .AND. mSCAN=121              && Alt-2
  191.            mRETVAL = 2
  192.        CASE mKEY=0 .AND. mSCAN=122              && Alt-3
  193.            mRETVAL = 3
  194.        CASE mKEY=17 .AND. mSCAN=0               && Cntrl-q
  195.            mRETVAL = 7
  196.        OTHERWISE
  197.            ?? CHR(7)                            && beep for invalid
  198.            mRETVAL = -HCHOICE
  199.     ENDCASE
  200.     HCHOICE = -mRETVAL
  201. RETURN
  202. * --------------------------------------------------------------------
  203. *   DISPHELP - This routine can be modified to be as simple or complex
  204. *   as desired. Use of the mCURHMENU and mCURVMENU parameters tell you
  205. *   exactly where you were when you entered the routine, so you can
  206. *   produce context sensitive help.
  207. * ---------------------------------------------------------------------
  208. PROCEDURE DISPHELP
  209. PARAMETERS mCURHMENU,mCURVMENU
  210.     CALL DBTOOLS WITH "21,12,8,40,12,75,0,3,2,1"
  211.     CALL DBTOOLS WITH "1,9,42,15,3,0,This is popup help for:"
  212.     CALL DBTOOLS WITH "1,10,45,0,3,0,HMENU option "+STR(mCURHMENU,2)
  213.     IF mCURVMENU>0
  214.         * If you press the help key while up on HMENU, you'll have VCHOICE=0
  215.         CALL DBTOOLS WITH "1,11,45,0,3,0,VMENU option "+STR(mCURVMENU,2)
  216.     ENDIF
  217.     CALL DBTOOLS WITH "10,12,43,15,3"
  218.     CALL DBTOOLS WITH "19,12"
  219. RETURN
  220.  
  221.  
  222. * ---------------------------------------------------------------------
  223. *   DRAWBG - draws screen backdrop for main menu.
  224. * ---------------------------------------------------------------------
  225. PROCEDURE DRAWBG
  226.  
  227. *   Flavor to taste.
  228. *   SIMPLE:
  229.     CALL DBTOOLS WITH "7,2,1,7,0"
  230.     CALL DBTOOLS WITH "5,1,0,1,79,1"
  231.  
  232. *   FANCY:
  233. *   Use function 12 to read a fancy screen image into a memory slot, then
  234. *   use a FADE from function 8 to display it in your startup initialization
  235. *   program. Assuming you saved the image in slot 1:
  236.  
  237.     CALL DBTOOLS WITH "14,1,0"              && display your image
  238.     * recolor your image to dark grey on white (makes it a little less obtrusive)
  239.     CALL DBTOOLS WITH "13,0,0,24,79,8,7"
  240.     CALL DBTOOLS WITH "5,1,0,1,79,1"        && erase menu bar area
  241.     CALL DBTOOLS WITH "5,24,0,24,79,1"      && erase status line
  242.     CALL DBTOOLS WITH "1,24,25,14,1,0,MAIN SYSTEM MENU"
  243.  
  244. RETURN
  245.  
  246.  
  247.