BDG Scenario 3

Properties (Form3.frm)

VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Properties 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Properties"
   ClientHeight    =   5040
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4695
   LinkTopic       =   "Form3"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5040
   ScaleWidth      =   4695
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame Frame1 
      BorderStyle     =   0  'None
      Caption         =   "Frame1"
      Height          =   3855
      Index           =   2
      Left            =   240
      TabIndex        =   14
      Top             =   480
      Visible         =   0   'False
      Width           =   4215
      Begin VB.TextBox Text4 
         Height          =   855
         Left            =   0
         Locked          =   -1  'True
         MultiLine       =   -1  'True
         ScrollBars      =   3  'Both
         TabIndex        =   21
         Top             =   1800
         Width           =   4215
      End
      Begin VB.TextBox Text3 
         Height          =   1215
         Left            =   0
         Locked          =   -1  'True
         MultiLine       =   -1  'True
         ScrollBars      =   3  'Both
         TabIndex        =   16
         Top             =   240
         Width           =   4215
      End
      Begin VB.TextBox Text2 
         Height          =   855
         Left            =   0
         Locked          =   -1  'True
         MultiLine       =   -1  'True
         ScrollBars      =   3  'Both
         TabIndex        =   15
         Top             =   3000
         Width           =   4215
      End
      Begin VB.Label Label8 
         Caption         =   "InnerText"
         Height          =   255
         Left            =   0
         TabIndex        =   20
         Top             =   0
         Width           =   2295
      End
      Begin VB.Label Label6 
         Caption         =   "BeforeEnd and AfterEnd"
         Height          =   255
         Left            =   0
         TabIndex        =   18
         Top             =   2760
         Width           =   2295
      End
      Begin VB.Label Label4 
         Caption         =   "BeforeBegin and AfterBegin"
         Height          =   255
         Left            =   0
         TabIndex        =   17
         Top             =   1560
         Width           =   2295
      End
   End
   Begin VB.Frame Frame1 
      BorderStyle     =   0  'None
      Caption         =   "Frame1"
      Height          =   3855
      Index           =   1
      Left            =   240
      TabIndex        =   4
      Top             =   480
      Visible         =   0   'False
      Width           =   4215
      Begin VB.TextBox Text1 
         Height          =   3375
         Left            =   0
         Locked          =   -1  'True
         MultiLine       =   -1  'True
         ScrollBars      =   3  'Both
         TabIndex        =   5
         Top             =   240
         Width           =   4215
      End
      Begin VB.Label Label7 
         Caption         =   "Inner HTML"
         Height          =   255
         Left            =   0
         TabIndex        =   19
         Top             =   0
         Width           =   2295
      End
   End
   Begin VB.Frame Frame1 
      BorderStyle     =   0  'None
      Caption         =   "Frame1"
      Height          =   3855
      Index           =   0
      Left            =   240
      TabIndex        =   3
      Top             =   480
      Visible         =   0   'False
      Width           =   4215
      Begin MSComctlLib.ListView ListView1 
         Height          =   2175
         Left            =   0
         TabIndex        =   13
         Top             =   1560
         Width           =   4215
         _ExtentX        =   7435
         _ExtentY        =   3836
         View            =   3
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   1
         NumItems        =   2
         BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            Text            =   "Attribute"
            Object.Width           =   2540
         EndProperty
         BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   1
            Text            =   "Value"
            Object.Width           =   5080
         EndProperty
      End
      Begin VB.Label Label5 
         Caption         =   "Other Attributes"
         Height          =   255
         Left            =   0
         TabIndex        =   12
         Top             =   1320
         Width           =   1935
      End
      Begin VB.Label lblLocation 
         Height          =   255
         Left            =   1320
         TabIndex        =   11
         Top             =   840
         Width           =   2775
      End
      Begin VB.Label lblName 
         Height          =   255
         Left            =   1320
         TabIndex        =   10
         Top             =   480
         Width           =   2775
      End
      Begin VB.Label lblID 
         Height          =   255
         Left            =   1320
         TabIndex        =   9
         Top             =   120
         Width           =   2775
      End
      Begin VB.Label Label3 
         Caption         =   "Location"
         Height          =   255
         Left            =   0
         TabIndex        =   8
         Top             =   840
         Width           =   1335
      End
      Begin VB.Label Label2 
         Caption         =   "Name"
         Height          =   255
         Left            =   0
         TabIndex        =   7
         Top             =   480
         Width           =   1335
      End
      Begin VB.Label Label1 
         Caption         =   "ID"
         Height          =   255
         Left            =   0
         TabIndex        =   6
         Top             =   120
         Width           =   1335
      End
   End
   Begin VB.CommandButton Command2 
      Caption         =   "Cancel"
      Height          =   375
      Left            =   3480
      TabIndex        =   2
      Top             =   4560
      Width           =   1095
   End
   Begin VB.CommandButton Command1 
      Caption         =   "OK"
      Default         =   -1  'True
      Height          =   375
      Left            =   2280
      TabIndex        =   1
      Top             =   4560
      Width           =   1095
   End
   Begin MSComctlLib.TabStrip TabStrip1 
      Height          =   4335
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   4455
      _ExtentX        =   7858
      _ExtentY        =   7646
      _Version        =   393216
      BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
         NumTabs         =   3
         BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            Caption         =   "General"
            ImageVarType    =   2
         EndProperty
         BeginProperty Tab2 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            Caption         =   "HTML"
            ImageVarType    =   2
         EndProperty
         BeginProperty Tab3 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            Caption         =   "Text"
            ImageVarType    =   2
         EndProperty
      EndProperty
   End
End
Attribute VB_Name = "Properties"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public Element As Variant

Private m_lastSel&

Private Sub Form_Load()
   Dim attrib As Variant
   
   m_lastSel = 0
   
   Frame1(0).Visible = True
   Frame1(1).Visible = False
   
   Debug.Assert Not IsEmpty(Element)
   
   Me.Caption = "Properties of " & Element.nodeName
   
   lblID.Caption = Element.Id
   lblName.Caption = Element.tagName
   lblLocation.Caption = Element.offsetTop & ", " & Element.offsetLeft & ", " & Element.offsetHeight & ", " & Element.offsetWidth
   
   ListView1.ListItems.Clear
   
   For Each attrib In Element.Attributes
      If attrib.specified Then
         Select Case attrib.nodeName
         Case "bgColor", "color", "text", "link", "aLink", "vLink":
            Call addAttribute(attrib.nodeName, ColorVal(attrib.nodeValue))
         Case "height", "width", "border", "cellPadding", "cellSpacing", "SIZE", _
              "leftMargin", "rightMargin", "topMargin", "bottomMargin":
            Call addAttribute(attrib.nodeName, SizeVal(attrib.nodeValue))
         Case "size":   ' used by FONT tags
            Call addAttribute(attrib.nodeName, FontSizeVal(attrib.nodeValue))
         Case Else:
            Call addAttribute(attrib.nodeName, attrib.nodeValue)
         End Select
      End If
   Next attrib
   
   Text1.Text = Element.innerHTML
   
   On Error Resume Next
   
   Text2.Text = Element.getAdjacentText("beforeEnd") & "</" & Element.tagName & ">"
   Text2.Text = Text2.Text & Element.getAdjacentText("afterEnd")
   
   Text3.Text = Element.innerText
   
   Text4.Text = Element.getAdjacentText("beforeBegin") & "<" & Element.tagName & ">"
   Text4.Text = Text4.Text & Element.getAdjacentText("afterBegin")
End Sub

Private Sub TabStrip1_Click()
   Dim idx&
   idx& = TabStrip1.SelectedItem.Index - 1
   If idx <> m_lastSel Then
       Frame1(m_lastSel).Visible = False
       Frame1(idx).Visible = True
       m_lastSel = idx
   End If
End Sub

Private Sub TabStrip1_KeyPress(KeyAscii As Integer)
   If KeyAscii = 27 Then Call Command2_Click   ' ESC closes
End Sub

Private Sub Command1_Click()
   Unload Me
End Sub

Private Sub Command2_Click()
   Unload Me
End Sub

Private Sub addAttribute(ByVal name As String, ByVal value As String)
   Dim item As MSComctlLib.ListItem
   Set item = ListView1.ListItems.Add(, name, name)
   item.SubItems(1) = value
End Sub