home *** CD-ROM | disk | FTP | other *** search
/ DOS Wares / doswares.zip / doswares / DATABASE / DBASE5 / CUA_SAMP.ZIP / DISPLNUM.PRG < prev    next >
Encoding:
Text File  |  1994-06-24  |  1.8 KB  |  56 lines

  1. *
  2. * File DISPLNUM.PRG
  3. * Sample program for "Programmer's Guide",
  4. * Chapter 20, "Introduction to UI object programming"
  5. *
  6. DEFINE FORM PreCalc;
  7.    PROPERTY ;
  8.       Text "Display a Number",;
  9.       Top 5,;
  10.       Width 30,;
  11.       Height 10,;
  12.       Left 20,;
  13.       Sizeable .F.
  14.  
  15. DEFINE ENTRYFIELD NumField OF PreCalc;
  16.    PROPERTY ;
  17.       Width 11,;
  18.       Top 0,;
  19.       Left 8,;
  20.       Value 0                  && Initially displays 0 in the entry field.
  21.  
  22. DEFINE PUSHBUTTON pb1 of PreCalc;
  23.    PROPERTY ;
  24.       Text "1",;
  25.       Width 5, ;
  26.       Top PreCalc.NumField.Top + 2,;
  27.       Left PreCalc.Width / 2 -3,;
  28.       OnClick NumClick         && Event handler when user clicks btn. is NumClick.
  29.  
  30. ***** Two form properties declared with dot reference notation. *****
  31.  
  32. PreCalc.Height = PreCalc.pb1.Top + PreCalc.pb1.Height + 3
  33. PreCalc.OnClose = "PreClcCls"
  34.  
  35. lVoid = PreCalc.pb1.SetFocus() && Gives pushbutton focus when form opens.
  36. lVoid = PreCalc.Open()         && Opens the form as a modeless window.
  37.  
  38. PROCEDURE NumClick
  39. *--------------------------------------------------------------------
  40. * This event handler takes the current value in the entry field, 
  41. * multiplies it by 10, and adds to it the numeric value of the 
  42. * pushbutton text. Because the entry field's value property changes,
  43. * the number it displays changes. Note use of form and this object
  44. * reference variables.
  45. *--------------------------------------------------------------------
  46.    form.NumField.Value = form.NumField.Value * 10 + VAL(this.Text)
  47. RETURN
  48.  
  49. PROCEDURE PreClcCls
  50. *--------------------------------------------------------------------
  51. * This OnClose event handler for form window PreCalc releases the 
  52. * object reference to the form, erasing it from memory.
  53. *--------------------------------------------------------------------
  54.    lVoid = this.Release()
  55. RETURN
  56.