home *** CD-ROM | disk | FTP | other *** search
- *******************************************************************************
- * PROGRAM: Openform.prg
- *
- * WRITTEN BY: Borland Samples Group
- *
- * DATE: 7/19/93
- *
- * UPDATED: 7/94
- *
- * REVISION: $Revision: 2.45 $
- *
- * VERSION: dBASE FOR WINDOWS 5.0
- *
- * DESCRIPTION: Openform shows how dBASE for Windows form commands work
- * together to open and close different kinds of forms.
- * A form is OPENed, containing a listbox of European countries,
- * and 2 pushbuttons -- Info and Cancel. Selecting Info or double
- * clicking the listbox brings up another form with information
- * about the selected country. You can bring up as many of these
- * forms as there are available workareas. Pressing Cancel in any
- * information form will close that form. Pressing Cancel in
- * the main form or closing the form through its system menu
- * will also close all the active information forms.
- *
- *
- * PARAMETERS: None
- *
- * CALLS: Buttons.cc (Custom controls file)
- *
- * USAGE: DO Openform
- *
- *******************************************************************************
- #define TRIMSTR(n) ltrim(str(n))
-
- create session
- set talk off
- set ldCheck off
-
- public formCnt
- formCnt = 0 && variable for count of information forms
-
- * since the program is event driven, you need to SET PROCEDURE to this file
- * so that at the end of the main program, when you are effectively located in
- * the command form, all the procedures will be available when a selection
- * is made.
-
- set procedure to program(1) additive
- set procedure to buttons.cc additive
-
- use country in select() order name
- select country
- define form Europe;
- property;
- top 5.10,;
- left 2.70,;
- height 6.87,;
- width 43.25,;
- text "European Countries",;
- sizeable .t.,;
- onclose OpenFormClean
-
- define infoButton countryInfo of Europe;
- property;
- top 1.72,;
- left 27.03,;
- default .t.,;
- onclick ShowInfo,;
- statusmessage;
- "Click here or double click in the listbox to get information about the highlighted country"
-
- define cancelButton countryCancel of Europe;
- property;
- top 3.69,;
- left 27.03
-
-
- define listbox country of Europe;
- property;
- onLeftDblClick ShowInfo,;
- top 1.02,;
- left 1.35,;
- height 5.10,;
- width 24.33,;
- dataSource "field country->name",;
- statusmessage "Double click on the desired country to get information about it."
- open form Europe &&noescape
-
- return
-
-
-
-
- *******************************************************************************
- procedure ShowInfo
-
- * Brings up the Info form. This form contains text objects that correspond
- * to whatever information was selected for viewing in the previous, SelectInfo
- * form, and an image containing the map of Europe highlighting the currently
- * selected country. "Cancel" in this form closes it.
- *******************************************************************************
- private cnt,background,newArea
-
- formCnt = formCnt + 1
- cnt = TRIMSTR(formCnt)
- use country again in select() alias country&cnt && each form must have its
- && own image
- select country&cnt
- go recno("country")
- background = iif(mod(formCnt,2)=0,"b","bg") && alternate background form color
- * don't let the forms go off the screen
-
- public Info&cnt
- define form Info&cnt;
- property;
- top mod(formCnt*2,20),;
- left 48.65 + mod(formCnt,10),;
- height 12.24,;
- width 48.65,;
- text "Info -- " + proper(name),;
- sizeable .t.,;
- colornormal "w+/&background",;
- onclose CloseThisInfo,;
- onselection {;form.Close()};
- custom;
- formcnt formcnt
- define text mapText of Info&cnt property;
- top 1.02,;
- left 1.35,;
- width 13.52,;
- text name,;
- colornormal "gr+/&background"
- * show the map of the current country highlighted on a map of Europe
- define image map of Info&cnt property;
- top 2.24,;
- left 1.35,;
- height 9.18,;
- width 24.33,;
- alignment 0,;
- dataSource "Memo map"
- define text popText of Info&cnt property;
- top 2.04,;
- left 29.73,;
- width 14.87,;
- text "Population:"
- define entryfield popInfo of Info&cnt property;
- top 3.06,;
- left 32.44,;
- width 14.87,;
- datalink "population",;
- enabled .f.,;
- oldstyle .t.,;
- border .f.,;
- function "T",;
- picture "999,999,999",;
- colornormal "gr+/&background"
- * show the capital field for the current country
- define text sizeText of Info&cnt property;
- top 4.08,;
- left 29.73,;
- text "Size:"
- define text sizeInfo of Info&cnt property;
- top 5.10,;
- left 32.44,;
- width 20.27,;
- function "T",;
- text transform(size,"999,999") + " sq. mi.",;
- colornormal "gr+/&background"
- define text capText of Info&cnt property;
- top 6.12,;
- left 29.73,;
- width 10.81,;
- text "Capital:"
- define text capInfo of Info&cnt property;
- top 7.14,;
- left 32.44,;
- width 13.52,;
- text ltrim(capital),;
- colornormal "gr+/&background"
- define CancelButton cancel of Info&cnt property;
- Onclick {;close form form},;
- top 9.18,;
- left 32.44
-
- * OPEN this form, and set focus to it. This command causes Info to be
- * added to the list of the currently open forms, but doesn't stop program
- * control flow at the OPEN line. This form is not modal.
- open form Info&cnt
- *set focus to Info&cnt
-
-
- *******************************************************************************
- procedure CloseThisInfo
-
- * On Selection routine for each Info&cnt form. Closes the database in the
- * area corresponding to the current form, and the form itself.
- *******************************************************************************
- private cnt
-
- cnt = TRIMSTR(this.formCnt)
- use in country&cnt
- release Info&cnt
-
- *******************************************************************************
- procedure OpenFormClean
-
- * This function closes the Country database, and releases all public variables.
- *******************************************************************************
- private i,cnt,curForm
- for i = formCnt to 1 step -1
- cnt = TRIMSTR(i)
- if type("Info" + cnt) <> "U"
- close form Info&cnt
- endif
- next i
- release formCnt
-
-
-
- ******************************* End of OpenForm.prg ****************************
-