home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a079 / 1.img / FPDG.LZH / VOL2NUM0 / MISC / MENUDEMO.PRG < prev    next >
Encoding:
Text File  |  1992-12-02  |  4.8 KB  |  155 lines

  1. **************************************************************
  2. *     * 8/20/92            MENUDEMO.PRG             11:02:20 *
  3. **************************************************************
  4. *     *                                                      *
  5. *     * Description:                                         *
  6. *     *  This program is a simple example of the use of the  *
  7. *     *  FoxPro 2.5 user-defined menu system commands        *
  8. *     *                                                      *
  9. **************************************************************
  10. *
  11. SET TALK OFF
  12. SET STATUS BAR ON
  13. *
  14.  
  15. *  Now, define all the objects.
  16. *
  17. *     First define the menu bar
  18. DEFINE MENU Sample 
  19. *
  20. *     Define the prompt pad objects for the Sample menu.
  21. *
  22. DEFINE PAD Files OF Sample PROMPT "\<File" 
  23. DEFINE PAD Edit OF Sample PROMPT "\<Edit" ;
  24.            MESSAGE "Edit database data" KEY CTRL+E,""
  25. DEFINE PAD Report OF Sample PROMPT "\<Report";
  26.         MESSAGE "Generate a report"
  27. DEFINE PAD Exit OF Sample PROMPT "E\<xit";
  28.         MESSAGE "Exit the application"
  29. *
  30. *     Now, define all popup objects.
  31. *
  32. *     Note that because the TO clause is omitted,
  33. *     the height and width are computed. The height
  34. *     is 9 rows high (7 bars + borders). The width
  35. *     is determined by the width of the widest bar 
  36. *     object, BAR 3. Each bar object is DEFINEd.
  37. *
  38. DEFINE POPUP Pop_File FROM 2,0 COLOR SCHEME 4
  39.   DEFINE BAR 1 OF Pop_File PROMPT "\<Use a Database ..."
  40.   DEFINE BAR 2 OF Pop_File PROMPT "Use a \<Form ..."
  41.   DEFINE BAR 3 OF Pop_File ;
  42.           PROMPT "\-"
  43.   DEFINE BAR 4 OF Pop_File PROMPT "  Create:" SKIP
  44.   DEFINE BAR 5 OF Pop_File PROMPT "\<Database";
  45.      MESSAGE "Create a database file" 
  46.   DEFINE BAR 6 OF Pop_File PROMPT "\<Screen"    ;
  47.      MESSAGE "Create or modify a screen file"
  48.   DEFINE BAR 7 OF Pop_File PROMPT "\<Report"  ;
  49.      MESSAGE "Create or modify a report form"
  50.  
  51. DEFINE POPUP Use_Dbf PROMPT FILE LIKE *.DBF FROM 3,20 ;
  52.         COLOR SCHEME 4
  53. DEFINE POPUP Use_Form PROMPT FILE LIKE *.FRM FROM 4,20 ;
  54.         COLOR SCHEME 4
  55.  
  56. *
  57. *  Now, establish actions.
  58. *     The POP_File popup displays whenever the cursor is
  59. *     on the File pad; it is never selected. There is an ON
  60. *     SELECTION for the other PAD objects: Edit, Report,
  61. *     and Exit.
  62. *
  63. ON PAD Files OF Sample ACTIVATE POPUP POP_File
  64. ON SELECTION PAD Edit OF Sample EDIT
  65. ON SELECTION PAD Report OF Sample DO Do_Report
  66. ON SELECTION PAD Exit OF Sample Do Quitter
  67. *
  68. ON SELECTION POPUP Pop_File DO P_File with BAR()
  69. ON SELECTION POPUP Use_Dbf  DO U_Dbf with PROMPT() 
  70. ON SELECTION POPUP Use_Form DO U_Form with PROMPT() 
  71. *
  72. *  Everything is defined and established. 
  73. *  Now activate the menu system
  74. *
  75. ACTIVATE MENU SAMPLE
  76.  
  77. RETURN
  78. **********************************************************
  79. *  Procedure Do_Report performs the actions for the Report
  80. *  pad object.
  81. *
  82. PROCEDURE Do_Report
  83. fn = GETFILE()
  84. IF NOT EMPTY(fn)
  85.    REPORT FORM fn
  86. ENDIF
  87. RETURN
  88. **********************************************************
  89. *  Procedure P_File performs the actions for the POP_File
  90. *  popup object. 
  91. *
  92.  
  93. PROCEDURE P_File
  94. PARAMETER Bar_Number        && Bar_number is the number of
  95.                             && the bar object
  96. SET MESSAGE TO
  97. @ 12,30 SAY ""
  98. DO CASE
  99. *
  100. *  Use a database file. This is done by activating a
  101. *  directory popup, then using the selected file.
  102. *  
  103.      Case Bar_Number = 1
  104.         ACTIVATE POPUP Use_Dbf
  105. *
  106. *     Set up a format file.
  107. *
  108.      CASE Bar_Number = 2
  109.         IF '' = dbf()
  110.            WAIT WINDOW ;
  111.         "Database file must be in use. Press any key to continue."
  112.         ELSE
  113.            ACTIVATE POPUP Use_Form
  114.         ENDIF
  115. *
  116. *     Create a database, form, and report files
  117. *
  118.      CASE Bar_Number = 5
  119.         CREATE
  120.      CASE Bar_Number = 6
  121.         CREATE SCREEN
  122.      CASE Bar_Number = 7
  123.         CREATE REPORT
  124. ENDCASE
  125. RETURN
  126. **********************************************************
  127. *  Procedure U_Dbf puts a file in use. It is executed when
  128. *  a file name is selected from a directory popup object.
  129. *
  130. PROCEDURE U_Dbf
  131. PARAMETER FileName          && FileName is the name of the 
  132.                             && selected file
  133. USE (FileName)
  134. DEACTIVATE POPUP
  135. RETURN
  136. **********************************************************
  137. *  Procedure U_Form establishes a format file.
  138. *  The file name is selected from a directory popup object.
  139. *
  140.  
  141. PROCEDURE U_Form
  142. PARAMETER FileName          && FileName is the name of the
  143.                             && selected file
  144. SET FORMAT TO (FileName)
  145. RETURN
  146.  
  147. ***********************************************************
  148. *  Procedure Quitter removes the menu bar and exits
  149. *
  150. PROCEDURE Quitter
  151. DEACTIVATE MENU Sample        && Deactivate menu before
  152.                               && you release it
  153. RELEASE MENU Sample EXTENDED  && Release entire menu system
  154. RETURN
  155.