home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 April B / Pcwk4b98.iso / Borland / Dbase50w / SAMPLES1.PAK / OPENFORM.PRG < prev    next >
Text File  |  1994-08-02  |  7KB  |  221 lines

  1. *******************************************************************************
  2. *  PROGRAM:      Openform.prg
  3. *
  4. *  WRITTEN BY:   Borland Samples Group
  5. *
  6. *  DATE:         7/19/93
  7. *
  8. *  UPDATED:      7/94
  9. *
  10. *  REVISION:     $Revision:   2.45  $
  11. *
  12. *  VERSION:      dBASE FOR WINDOWS 5.0
  13. *
  14. *  DESCRIPTION:  Openform shows how dBASE for Windows form commands work
  15. *                together to open and close different kinds of forms.
  16. *                A form is OPENed, containing a listbox of European countries,
  17. *                and 2 pushbuttons -- Info and Cancel.  Selecting Info or double
  18. *                clicking the listbox brings up another form with information
  19. *                about the selected country.  You can bring up as many of these
  20. *                forms as there are available workareas. Pressing Cancel in any
  21. *                information form will close that form.  Pressing Cancel in
  22. *                the main form or closing the form through its system menu
  23. *                will also close all the active information forms.
  24. *
  25. *
  26. *  PARAMETERS:   None
  27. *
  28. *  CALLS:        Buttons.cc  (Custom controls file)
  29. *
  30. *  USAGE:        DO Openform
  31. *
  32. *******************************************************************************
  33. #define TRIMSTR(n)  ltrim(str(n))
  34.  
  35. create session
  36. set talk off
  37. set ldCheck off
  38.  
  39. public formCnt
  40. formCnt = 0  && variable for count of information forms
  41.  
  42. * since the program is event driven, you need to SET PROCEDURE to this file
  43. * so that at the end of the main program, when you are effectively located in
  44. * the command form, all the procedures will be available when a selection
  45. * is made.
  46.  
  47. set procedure to program(1) additive
  48. set procedure to buttons.cc additive
  49.  
  50. use country in select() order name
  51. select country
  52. define form Europe;
  53.    property;
  54.       top 5.10,;
  55.       left 2.70,;
  56.       height 6.87,;
  57.       width 43.25,;
  58.       text "European Countries",;
  59.       sizeable .t.,;
  60.       onclose OpenFormClean
  61.  
  62. define infoButton countryInfo of Europe;
  63.    property;
  64.       top  1.72,;
  65.       left 27.03,;
  66.       default .t.,;
  67.       onclick ShowInfo,;
  68.       statusmessage;
  69.          "Click here or double click in the listbox to get information about the highlighted country"
  70.  
  71. define cancelButton countryCancel of Europe;
  72.    property;
  73.       top  3.69,;
  74.       left 27.03
  75.  
  76.  
  77. define listbox country of Europe;
  78.    property;
  79.       onLeftDblClick ShowInfo,;
  80.       top 1.02,;
  81.       left 1.35,;
  82.       height 5.10,;
  83.       width 24.33,;
  84.       dataSource "field country->name",;
  85.       statusmessage "Double click on the desired country to get information about it."
  86. open form Europe &&noescape
  87.  
  88. return
  89.  
  90.  
  91.  
  92.  
  93. *******************************************************************************
  94. procedure ShowInfo
  95.  
  96. * Brings up the Info form.  This form contains text objects that correspond
  97. * to whatever information was selected for viewing in the previous, SelectInfo
  98. * form, and an image containing the map of Europe highlighting the currently
  99. * selected country.  "Cancel" in this form closes it.
  100. *******************************************************************************
  101. private cnt,background,newArea
  102.  
  103. formCnt = formCnt + 1
  104. cnt = TRIMSTR(formCnt)
  105. use country again in select() alias country&cnt  && each form must have its
  106.                                                  && own image
  107. select country&cnt
  108. go recno("country")
  109. background = iif(mod(formCnt,2)=0,"b","bg")  && alternate background form color
  110. * don't let the forms go off the screen
  111.  
  112. public Info&cnt
  113. define form Info&cnt;
  114.    property;
  115.       top  mod(formCnt*2,20),;
  116.       left 48.65 + mod(formCnt,10),;
  117.       height 12.24,;
  118.       width 48.65,;
  119.       text "Info -- " + proper(name),;
  120.       sizeable .t.,;
  121.       colornormal "w+/&background",;
  122.       onclose CloseThisInfo,;
  123.       onselection {;form.Close()};
  124.    custom;
  125.       formcnt formcnt
  126. define text mapText of Info&cnt property;
  127.    top  1.02,;
  128.    left 1.35,;
  129.    width 13.52,;
  130.    text name,;
  131.    colornormal  "gr+/&background"
  132. * show the map of the current country highlighted on a map of Europe
  133. define image map of Info&cnt property;
  134.    top  2.24,;
  135.    left 1.35,;
  136.    height 9.18,;
  137.    width 24.33,;
  138.    alignment 0,;
  139.    dataSource "Memo map"
  140. define text popText of Info&cnt property;
  141.    top  2.04,;
  142.    left 29.73,;
  143.    width 14.87,;
  144.    text "Population:"
  145. define entryfield popInfo of Info&cnt property;
  146.    top  3.06,;
  147.    left 32.44,;
  148.    width 14.87,;
  149.    datalink "population",;
  150.    enabled .f.,;
  151.    oldstyle .t.,;
  152.    border .f.,;
  153.    function "T",;
  154.    picture "999,999,999",;
  155.    colornormal "gr+/&background"
  156. * show the capital field for the current country
  157. define text sizeText of Info&cnt property;
  158.    top 4.08,;
  159.    left 29.73,;
  160.    text "Size:"
  161. define text sizeInfo of Info&cnt property;
  162.    top 5.10,;
  163.    left 32.44,;
  164.    width 20.27,;
  165.    function "T",;
  166.    text transform(size,"999,999") + " sq. mi.",;
  167.    colornormal "gr+/&background"
  168. define text capText of Info&cnt property;
  169.    top  6.12,;
  170.    left 29.73,;
  171.    width 10.81,;
  172.    text "Capital:"
  173. define text capInfo of Info&cnt property;
  174.    top  7.14,;
  175.    left 32.44,;
  176.    width 13.52,;
  177.    text ltrim(capital),;
  178.    colornormal "gr+/&background"
  179. define CancelButton cancel of Info&cnt property;
  180.    Onclick {;close form form},;
  181.    top  9.18,;
  182.    left 32.44
  183.  
  184. * OPEN this form, and set focus to it.  This command causes Info to be
  185. * added to the list of the currently open forms, but doesn't stop program
  186. * control flow at the OPEN line.  This form is not modal.
  187. open form Info&cnt
  188. *set focus to Info&cnt
  189.  
  190.  
  191. *******************************************************************************
  192. procedure CloseThisInfo
  193.  
  194. * On Selection routine for each Info&cnt form.  Closes the database in the
  195. * area corresponding to the current form, and the form itself.
  196. *******************************************************************************
  197. private cnt
  198.  
  199. cnt = TRIMSTR(this.formCnt)
  200. use in country&cnt
  201. release Info&cnt
  202.  
  203. *******************************************************************************
  204. procedure OpenFormClean
  205.  
  206. * This function closes the Country database, and releases all public variables.
  207. *******************************************************************************
  208. private i,cnt,curForm
  209. for i = formCnt to 1 step -1
  210.    cnt = TRIMSTR(i)
  211.    if type("Info" + cnt) <> "U"
  212.      close form Info&cnt
  213.    endif
  214. next i
  215. release formCnt
  216.  
  217.  
  218.  
  219. ******************************* End of OpenForm.prg ****************************
  220.  
  221.