home *** CD-ROM | disk | FTP | other *** search
- **************************************************************
- * * 8/20/92 MENUDEMO.PRG 11:02:20 *
- **************************************************************
- * * *
- * * Description: *
- * * This program is a simple example of the use of the *
- * * FoxPro 2.5 user-defined menu system commands *
- * * *
- **************************************************************
- *
- SET TALK OFF
- SET STATUS BAR ON
- *
-
- * Now, define all the objects.
- *
- * First define the menu bar
- DEFINE MENU Sample
- *
- * Define the prompt pad objects for the Sample menu.
- *
- DEFINE PAD Files OF Sample PROMPT "\<File"
- DEFINE PAD Edit OF Sample PROMPT "\<Edit" ;
- MESSAGE "Edit database data" KEY CTRL+E,""
- DEFINE PAD Report OF Sample PROMPT "\<Report";
- MESSAGE "Generate a report"
- DEFINE PAD Exit OF Sample PROMPT "E\<xit";
- MESSAGE "Exit the application"
- *
- * Now, define all popup objects.
- *
- * Note that because the TO clause is omitted,
- * the height and width are computed. The height
- * is 9 rows high (7 bars + borders). The width
- * is determined by the width of the widest bar
- * object, BAR 3. Each bar object is DEFINEd.
- *
- DEFINE POPUP Pop_File FROM 2,0 COLOR SCHEME 4
- DEFINE BAR 1 OF Pop_File PROMPT "\<Use a Database ..."
- DEFINE BAR 2 OF Pop_File PROMPT "Use a \<Form ..."
- DEFINE BAR 3 OF Pop_File ;
- PROMPT "\-"
- DEFINE BAR 4 OF Pop_File PROMPT " Create:" SKIP
- DEFINE BAR 5 OF Pop_File PROMPT "\<Database";
- MESSAGE "Create a database file"
- DEFINE BAR 6 OF Pop_File PROMPT "\<Screen" ;
- MESSAGE "Create or modify a screen file"
- DEFINE BAR 7 OF Pop_File PROMPT "\<Report" ;
- MESSAGE "Create or modify a report form"
-
- DEFINE POPUP Use_Dbf PROMPT FILE LIKE *.DBF FROM 3,20 ;
- COLOR SCHEME 4
- DEFINE POPUP Use_Form PROMPT FILE LIKE *.FRM FROM 4,20 ;
- COLOR SCHEME 4
-
- *
- * Now, establish actions.
- * The POP_File popup displays whenever the cursor is
- * on the File pad; it is never selected. There is an ON
- * SELECTION for the other PAD objects: Edit, Report,
- * and Exit.
- *
- ON PAD Files OF Sample ACTIVATE POPUP POP_File
- ON SELECTION PAD Edit OF Sample EDIT
- ON SELECTION PAD Report OF Sample DO Do_Report
- ON SELECTION PAD Exit OF Sample Do Quitter
- *
- ON SELECTION POPUP Pop_File DO P_File with BAR()
- ON SELECTION POPUP Use_Dbf DO U_Dbf with PROMPT()
- ON SELECTION POPUP Use_Form DO U_Form with PROMPT()
- *
- * Everything is defined and established.
- * Now activate the menu system
- *
- ACTIVATE MENU SAMPLE
-
- RETURN
- **********************************************************
- * Procedure Do_Report performs the actions for the Report
- * pad object.
- *
- PROCEDURE Do_Report
- fn = GETFILE()
- IF NOT EMPTY(fn)
- REPORT FORM fn
- ENDIF
- RETURN
- **********************************************************
- * Procedure P_File performs the actions for the POP_File
- * popup object.
- *
-
- PROCEDURE P_File
- PARAMETER Bar_Number && Bar_number is the number of
- && the bar object
- SET MESSAGE TO
- @ 12,30 SAY ""
- DO CASE
- *
- * Use a database file. This is done by activating a
- * directory popup, then using the selected file.
- *
- Case Bar_Number = 1
- ACTIVATE POPUP Use_Dbf
- *
- * Set up a format file.
- *
- CASE Bar_Number = 2
- IF '' = dbf()
- WAIT WINDOW ;
- "Database file must be in use. Press any key to continue."
- ELSE
- ACTIVATE POPUP Use_Form
- ENDIF
- *
- * Create a database, form, and report files
- *
- CASE Bar_Number = 5
- CREATE
- CASE Bar_Number = 6
- CREATE SCREEN
- CASE Bar_Number = 7
- CREATE REPORT
- ENDCASE
- RETURN
- **********************************************************
- * Procedure U_Dbf puts a file in use. It is executed when
- * a file name is selected from a directory popup object.
- *
- PROCEDURE U_Dbf
- PARAMETER FileName && FileName is the name of the
- && selected file
- USE (FileName)
- DEACTIVATE POPUP
- RETURN
- **********************************************************
- * Procedure U_Form establishes a format file.
- * The file name is selected from a directory popup object.
- *
-
- PROCEDURE U_Form
- PARAMETER FileName && FileName is the name of the
- && selected file
- SET FORMAT TO (FileName)
- RETURN
-
- ***********************************************************
- * Procedure Quitter removes the menu bar and exits
- *
- PROCEDURE Quitter
- DEACTIVATE MENU Sample && Deactivate menu before
- && you release it
- RELEASE MENU Sample EXTENDED && Release entire menu system
- RETURN
-