home *** CD-ROM | disk | FTP | other *** search
/ The Best of Select: Windows 95 Special 2 / WIN95_2.bin / utils / envelop / envelop.6 / Tools / Bootcamp / basic / arrayopt / arrayopt.eto < prev    next >
Encoding:
Text File  |  1996-07-08  |  3.0 KB  |  121 lines

  1. Type MyOptionButton From OptionButton
  2.  
  3.   ' METHODS for object: MyOptionButton
  4.   Sub Click()
  5.     Dim red, green, blue As Integer
  6.   
  7.     ' If there is no parent, then don't do anything
  8.     If Not Parent Then Exit Sub
  9.   
  10.     red = rnd() * 255
  11.     green = rnd() * 255
  12.     blue = rnd() * 255
  13.   
  14.     Parent.lblColorDisplay.BackColor = RGB(red, green, blue)
  15.   
  16.   End Sub
  17.  
  18. End Type
  19.  
  20. Type ArrayOptBtnMasterForm From SampleMasterForm
  21.   Dim lblColorDisplay As New Label
  22.   Dim btnAdd As New Button
  23.   Dim btnRemove As New Button
  24.   Dim OptionCounter As Integer
  25.   Dim MyOptionButton1 As New MyOptionButton
  26.  
  27.   ' METHODS for object: ArrayOptBtnMasterForm
  28.   Sub btnAdd_Click()
  29.     Dim name As String
  30.     Dim o As Object
  31.   
  32.     If OptionCounter == 8 Then Exit Sub
  33.   
  34.     OptionCounter = OptionCounter + 1
  35.   
  36.     name = "MyOptionButton" & OptionCounter
  37.     o = EmbedObject(ArrayOptBtnMasterForm, MyOptionButton, name)
  38.   
  39.     o.Caption = name
  40.     o.Left = 1200
  41.     o.Width = 2100
  42.     o.Height = 300
  43.   
  44.   
  45.     o.Top = 1200 + (OptionCounter * 300)
  46.   
  47.   End Sub
  48.  
  49.   Sub btnRemove_Click()
  50.     Dim o As Object
  51.     Dim name As String
  52.   
  53.     If OptionCounter == 1 Then Exit Sub
  54.   
  55.     name = "MyOptionButton" & OptionCounter
  56.     o = FindEmbed(ArrayOptBtnMasterForm, name)
  57.     DestroyObject(o)
  58.   
  59.     OptionCounter = OptionCounter - 1
  60.   
  61.   End Sub
  62.  
  63.   Sub ResetApplication_Click ()
  64.     dim i as integer
  65.     i = 0
  66.     While i < Controls.Count
  67.       If ((TypeOf Controls(i) Is MyOptionButton) && (Controls(i) <> MyOptionButton1)) Then 
  68.         DestroyObject(Controls(i))
  69.       Else 
  70.         i = i + 1
  71.       End If
  72.     Wend
  73.     OptionCounter = 1
  74.     lblColorDisplay.BackColor = RGB(255, 255, 255)
  75.   
  76.   End Sub
  77.  
  78. End Type
  79.  
  80. Begin Code
  81. ' Reconstruction commands for object: MyOptionButton
  82. '
  83.   With MyOptionButton
  84.     .Move(0, 0, 0, 0)
  85.   End With  'MyOptionButton
  86. ' Reconstruction commands for object: ArrayOptBtnMasterForm
  87. '
  88.   With ArrayOptBtnMasterForm
  89.     .Caption := "Option Button Array Demonstration"
  90.     .Move(5295, 1365, 6105, 5055)
  91.     .OptionCounter := 1
  92.     .SampleDir := "W:\Examples\arrayopt\"
  93.     .SampleName := "arrayopt"
  94.     .DefaultButton := .btnAdd
  95.     .CancelButton := .btnRemove
  96.     With .lblColorDisplay
  97.       .BackColor := 16777215
  98.       .Move(300, 300, 5400, 900)
  99.       .BorderStyle := "Fixed Single"
  100.     End With  'ArrayOptBtnMasterForm.lblColorDisplay
  101.     With .btnAdd
  102.       .Caption := "&Add"
  103.       .Move(4650, 1500, 1050, 450)
  104.     End With  'ArrayOptBtnMasterForm.btnAdd
  105.     With .btnRemove
  106.       .Caption := "&Remove"
  107.       .Move(4650, 2100, 1050, 450)
  108.     End With  'ArrayOptBtnMasterForm.btnRemove
  109.     With .MyOptionButton1
  110.       .Caption := "MyOptionButton1"
  111.       .Move(1200, 1500, 2100, 300)
  112.       .TabStop := True
  113.       .TabGroup := True
  114.       .Value := True
  115.     End With  'ArrayOptBtnMasterForm.MyOptionButton1
  116.     With .helpfile
  117.       .FileName := "W:\Examples\arrayopt\arrayopt.hlp"
  118.     End With  'ArrayOptBtnMasterForm.helpfile
  119.   End With  'ArrayOptBtnMasterForm
  120. End Code
  121.