home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 February / PCWK0297.iso / envelop / envelop.6 / Tools / Bootcamp / concepts / objref / objref.eto < prev    next >
Text File  |  1996-07-08  |  4KB  |  137 lines

  1. Type ObjectReferenceForm From SampleMasterForm
  2.   Dim MyRef As Object
  3.   Dim Button1 As New Button
  4.   Dim BtnEnable As New Button
  5.   Dim OptionButton1 As New OptionButton
  6.   Dim ScrollBar1 As New ScrollBar
  7.   Dim TextBox1 As New TextBox
  8.   Dim CheckBox1 As New CheckBox
  9.   Dim ComboBox1 As New ComboBox
  10.   Dim ListBox1 As New ListBox
  11.   Dim BtnCodeExample As New Button
  12.  
  13.   ' METHODS for object: ObjectReferenceForm
  14.   Sub OptionButton1_GotFocus()
  15.     MyRef = OptionButton1
  16.   End Sub
  17.  
  18.   Sub Button1_GotFocus()
  19.     MyRef = Button1
  20.   End Sub
  21.  
  22.   Sub ScrollBar1_GotFocus()
  23.     MyRef = ScrollBar1
  24.   End Sub
  25.  
  26.   Sub Label1_GotFocus()
  27.     MyRef = Label1
  28.   End Sub
  29.  
  30.   Sub TextBox1_GotFocus()
  31.     MyRef = TextBox1
  32.   End Sub
  33.  
  34.   Sub ComboBox1_GotFocus()
  35.     MyRef = ComboBox1
  36.   End Sub
  37.  
  38.   Sub CheckBox1_GotFocus()
  39.     MyRef = CheckBox1
  40.   End Sub
  41.  
  42.   Sub ListBox1_GotFocus()
  43.     MyRef = ListBox1
  44.   End Sub
  45.  
  46.   Sub BtnEnable_Click()
  47.     MyRef.Enabled = Not MyRef.Enabled
  48.   End Sub
  49.  
  50.   Sub BtnCodeExample_Click()
  51.     Dim b As Button
  52.     Dim c As Control
  53.     Dim i As Integer
  54.   
  55.     For i = 0 To Controls.Count - 1
  56.       c = Controls(i)
  57.       ' TypeOf checks to see if object is of a specific type
  58.       If TypeOf c Is Button Then 
  59.         b = c
  60.       Else 
  61.         ' This is like a "0" used for object references
  62.         b = Nothing
  63.       End If
  64.       ' Same as saying If Not (Nothing) Then .....
  65.       If b Then 
  66.         InfoBox.Message("", b.Caption)
  67.       End If
  68.     Next i
  69.   End Sub
  70.  
  71.   Sub ResetApplication_Click
  72.     Button1.Enabled = True
  73.     TextBox1.Enabled = True
  74.     OptionButton1.Enabled = True
  75.     CheckBox1.Enabled = True
  76.     ListBox1.Enabled = True
  77.     ScrollBar1.Enabled = True
  78.     ComboBox1.Enabled = True
  79.     ' Check to see of the ListBox needs to be configured
  80.     If ListBox1.ListCount == 0 Then 
  81.       ListBox1.AddItem "ListBox1"
  82.     End If
  83.   End Sub
  84.  
  85. End Type
  86.  
  87. Begin Code
  88. ' Reconstruction commands for object: ObjectReferenceForm
  89. '
  90.   With ObjectReferenceForm
  91.     .Caption := "Object Referencing Example"
  92.     .Move(3735, 1845, 5970, 4305)
  93.     .MyRef := ObjectReferenceForm.Button1
  94.     With .Button1
  95.       .Caption := "Button1"
  96.       .Move(300, 300, 2100, 450)
  97.     End With  'ObjectReferenceForm.Button1
  98.     With .BtnEnable
  99.       .Caption := "Enable/Disable"
  100.       .Move(300, 2850, 1815, 450)
  101.     End With  'ObjectReferenceForm.BtnEnable
  102.     With .OptionButton1
  103.       .Caption := "OptionButton1"
  104.       .Move(300, 1650, 1800, 330)
  105.       .TabStop := True
  106.     End With  'ObjectReferenceForm.OptionButton1
  107.     With .ScrollBar1
  108.       .Caption := "ScrollBar1"
  109.       .Move(3300, 2100, 2250, 285)
  110.       .Orientation := "Horizontal"
  111.       .Move(3300, 2100, 2250, 285)
  112.     End With  'ObjectReferenceForm.ScrollBar1
  113.     With .TextBox1
  114.       .Caption := "TextBox1"
  115.       .Move(300, 900, 2100, 450)
  116.     End With  'ObjectReferenceForm.TextBox1
  117.     With .CheckBox1
  118.       .Caption := "CheckBox1"
  119.       .Move(300, 2100, 1500, 300)
  120.     End With  'ObjectReferenceForm.CheckBox1
  121.     With .ComboBox1
  122.       .Move(3300, 300, 2250, 360)
  123.     End With  'ObjectReferenceForm.ComboBox1
  124.     With .ListBox1
  125.       .Caption := "ListBox1"
  126.       .Move(3300, 900, 2250, 990)
  127.     End With  'ObjectReferenceForm.ListBox1
  128.     With .BtnCodeExample
  129.       .Caption := "Code Example"
  130.       .Move(3900, 2850, 1650, 450)
  131.     End With  'ObjectReferenceForm.BtnCodeExample
  132.     With .helpfile
  133.       .FileName := "C:\ENVELOP\PROGRAM\envelop.hlp"
  134.     End With  'ObjectReferenceForm.helpfile
  135.   End With  'ObjectReferenceForm
  136. End Code
  137.