home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 January / PCWorld_2001-01_cd.bin / Software / Topware / xmlspy / xmlspy35.exe / Main / WalkXMLDlg.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2000-11-20  |  16.0 KB  |  512 lines

  1. VERSION 5.00
  2. Begin VB.Form WalkXMLDlg 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Walk XML tree"
  5.    ClientHeight    =   5595
  6.    ClientLeft      =   8490
  7.    ClientTop       =   675
  8.    ClientWidth     =   7740
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   5595
  13.    ScaleWidth      =   7740
  14.    ShowInTaskbar   =   0   'False
  15.    Begin VB.CommandButton BtnSetFocus 
  16.       Caption         =   "set focus"
  17.       Height          =   375
  18.       Left            =   3840
  19.       TabIndex        =   27
  20.       Top             =   4200
  21.       Width           =   1095
  22.    End
  23.    Begin VB.CommandButton BtnEnd 
  24.       Caption         =   "end changes"
  25.       Height          =   375
  26.       Left            =   5160
  27.       TabIndex        =   24
  28.       Top             =   720
  29.       Width           =   1095
  30.    End
  31.    Begin VB.CommandButton BtnStart 
  32.       Caption         =   "start changes"
  33.       Height          =   375
  34.       Left            =   5160
  35.       TabIndex        =   23
  36.       Top             =   240
  37.       Width           =   1095
  38.    End
  39.    Begin VB.CommandButton BtnEraseAll 
  40.       Caption         =   "erase all"
  41.       Height          =   375
  42.       Left            =   5160
  43.       TabIndex        =   13
  44.       Top             =   2880
  45.       Width           =   1095
  46.    End
  47.    Begin VB.CommandButton BtnErase 
  48.       Caption         =   "erase current"
  49.       Height          =   375
  50.       Left            =   5160
  51.       TabIndex        =   12
  52.       Top             =   2400
  53.       Width           =   1095
  54.    End
  55.    Begin VB.CommandButton BtnAppend 
  56.       Caption         =   "append child"
  57.       Height          =   375
  58.       Left            =   3840
  59.       TabIndex        =   11
  60.       Top             =   2880
  61.       Width           =   1095
  62.    End
  63.    Begin VB.CommandButton BtnInsert 
  64.       Caption         =   "insert child"
  65.       Height          =   375
  66.       Left            =   3840
  67.       TabIndex        =   10
  68.       Top             =   2400
  69.       Width           =   1095
  70.    End
  71.    Begin VB.TextBox EditKindChild 
  72.       Enabled         =   0   'False
  73.       Height          =   285
  74.       Left            =   1050
  75.       Locked          =   -1  'True
  76.       TabIndex        =   4
  77.       Text            =   "Text1"
  78.       Top             =   2040
  79.       Width           =   2295
  80.    End
  81.    Begin VB.TextBox EditNameChild 
  82.       Height          =   285
  83.       Left            =   1050
  84.       TabIndex        =   5
  85.       Text            =   "Text1"
  86.       Top             =   2400
  87.       Width           =   2295
  88.    End
  89.    Begin VB.TextBox EditValueChild 
  90.       Height          =   285
  91.       Left            =   1050
  92.       TabIndex        =   6
  93.       Text            =   "Text1"
  94.       Top             =   2760
  95.       Width           =   2295
  96.    End
  97.    Begin VB.CommandButton BtnParent 
  98.       Caption         =   "go to parent"
  99.       Height          =   375
  100.       Left            =   3840
  101.       TabIndex        =   9
  102.       Top             =   1680
  103.       Width           =   1095
  104.    End
  105.    Begin VB.CommandButton BtnStepDown 
  106.       Caption         =   "step down"
  107.       Height          =   375
  108.       Left            =   3840
  109.       TabIndex        =   8
  110.       Top             =   1200
  111.       Width           =   1095
  112.    End
  113.    Begin VB.CommandButton BtnNextChild 
  114.       Caption         =   "next child"
  115.       Height          =   375
  116.       Left            =   3840
  117.       TabIndex        =   7
  118.       Top             =   240
  119.       Width           =   1095
  120.    End
  121.    Begin VB.TextBox EditValue 
  122.       Height          =   285
  123.       Left            =   1050
  124.       Locked          =   -1  'True
  125.       TabIndex        =   3
  126.       Text            =   "Text1"
  127.       Top             =   1335
  128.       Width           =   2295
  129.    End
  130.    Begin VB.TextBox EditName 
  131.       Height          =   285
  132.       Left            =   1050
  133.       Locked          =   -1  'True
  134.       TabIndex        =   2
  135.       Text            =   "Text1"
  136.       Top             =   975
  137.       Width           =   2295
  138.    End
  139.    Begin VB.TextBox EditKind 
  140.       Enabled         =   0   'False
  141.       Height          =   285
  142.       Left            =   1050
  143.       Locked          =   -1  'True
  144.       TabIndex        =   1
  145.       Text            =   "Text1"
  146.       Top             =   615
  147.       Width           =   2295
  148.    End
  149.    Begin VB.CommandButton OKButton 
  150.       Caption         =   "OK"
  151.       Height          =   375
  152.       Left            =   6480
  153.       TabIndex        =   0
  154.       Top             =   5040
  155.       Width           =   1095
  156.    End
  157.    Begin VB.Frame Frame1 
  158.       Caption         =   "XMLData"
  159.       Height          =   4425
  160.       Left            =   120
  161.       TabIndex        =   14
  162.       Top             =   135
  163.       Width           =   3435
  164.       Begin VB.TextBox EditFocusValue 
  165.          Height          =   285
  166.          Left            =   960
  167.          TabIndex        =   30
  168.          Text            =   "Text3"
  169.          Top             =   3960
  170.          Width           =   2295
  171.       End
  172.       Begin VB.TextBox EditFocusName 
  173.          Height          =   285
  174.          Left            =   960
  175.          Locked          =   -1  'True
  176.          TabIndex        =   29
  177.          Text            =   "Text2"
  178.          Top             =   3600
  179.          Width           =   2295
  180.       End
  181.       Begin VB.TextBox EditFocusKind 
  182.          Enabled         =   0   'False
  183.          Height          =   285
  184.          Left            =   960
  185.          TabIndex        =   28
  186.          Text            =   "Text1"
  187.          Top             =   3240
  188.          Width           =   2295
  189.       End
  190.       Begin VB.Label Label12 
  191.          Caption         =   "current focus in grid"
  192.          BeginProperty Font 
  193.             Name            =   "MS Sans Serif"
  194.             Size            =   8.25
  195.             Charset         =   0
  196.             Weight          =   700
  197.             Underline       =   0   'False
  198.             Italic          =   0   'False
  199.             Strikethrough   =   0   'False
  200.          EndProperty
  201.          Height          =   255
  202.          Left            =   180
  203.          TabIndex        =   34
  204.          Top             =   2985
  205.          Width           =   1815
  206.       End
  207.       Begin VB.Label Label11 
  208.          Caption         =   "Value:"
  209.          Height          =   255
  210.          Left            =   180
  211.          TabIndex        =   33
  212.          Top             =   3960
  213.          Width           =   720
  214.       End
  215.       Begin VB.Label Label10 
  216.          Caption         =   "Name:"
  217.          Height          =   255
  218.          Left            =   180
  219.          TabIndex        =   32
  220.          Top             =   3600
  221.          Width           =   720
  222.       End
  223.       Begin VB.Label Label9 
  224.          Caption         =   "Kind:"
  225.          Height          =   255
  226.          Left            =   180
  227.          TabIndex        =   31
  228.          Top             =   3255
  229.          Width           =   720
  230.       End
  231.       Begin VB.Label TxtMayChildren 
  232.          Caption         =   "children"
  233.          Height          =   240
  234.          Left            =   1335
  235.          TabIndex        =   26
  236.          Top             =   1620
  237.          Width           =   1755
  238.       End
  239.       Begin VB.Label Label8 
  240.          Caption         =   "current child"
  241.          BeginProperty Font 
  242.             Name            =   "MS Sans Serif"
  243.             Size            =   8.25
  244.             Charset         =   0
  245.             Weight          =   700
  246.             Underline       =   0   'False
  247.             Italic          =   0   'False
  248.             Strikethrough   =   0   'False
  249.          EndProperty
  250.          Height          =   255
  251.          Left            =   165
  252.          TabIndex        =   22
  253.          Top             =   1620
  254.          Width           =   1455
  255.       End
  256.       Begin VB.Label Label7 
  257.          Caption         =   "Kind:"
  258.          Height          =   255
  259.          Left            =   165
  260.          TabIndex        =   21
  261.          Top             =   1935
  262.          Width           =   720
  263.       End
  264.       Begin VB.Label Label6 
  265.          Caption         =   "Name:"
  266.          Height          =   255
  267.          Left            =   165
  268.          TabIndex        =   20
  269.          Top             =   2280
  270.          Width           =   720
  271.       End
  272.       Begin VB.Label Label5 
  273.          Caption         =   "Value:"
  274.          Height          =   255
  275.          Left            =   165
  276.          TabIndex        =   19
  277.          Top             =   2640
  278.          Width           =   720
  279.       End
  280.       Begin VB.Label Label4 
  281.          Caption         =   "parent"
  282.          BeginProperty Font 
  283.             Name            =   "MS Sans Serif"
  284.             Size            =   8.25
  285.             Charset         =   0
  286.             Weight          =   700
  287.             Underline       =   0   'False
  288.             Italic          =   0   'False
  289.             Strikethrough   =   0   'False
  290.          EndProperty
  291.          Height          =   255
  292.          Left            =   195
  293.          TabIndex        =   18
  294.          Top             =   225
  295.          Width           =   735
  296.       End
  297.       Begin VB.Label Label3 
  298.          Caption         =   "Value:"
  299.          Height          =   255
  300.          Left            =   195
  301.          TabIndex        =   17
  302.          Top             =   1245
  303.          Width           =   720
  304.       End
  305.       Begin VB.Label Label2 
  306.          Caption         =   "Name:"
  307.          Height          =   255
  308.          Left            =   195
  309.          TabIndex        =   16
  310.          Top             =   885
  311.          Width           =   720
  312.       End
  313.       Begin VB.Label Label1 
  314.          Caption         =   "Kind:"
  315.          Height          =   255
  316.          Left            =   195
  317.          TabIndex        =   15
  318.          Top             =   510
  319.          Width           =   720
  320.       End
  321.    End
  322.    Begin VB.Label TxtUpdate 
  323.       Caption         =   "updates"
  324.       BeginProperty Font 
  325.          Name            =   "MS Sans Serif"
  326.          Size            =   8.25
  327.          Charset         =   0
  328.          Weight          =   700
  329.          Underline       =   0   'False
  330.          Italic          =   0   'False
  331.          Strikethrough   =   0   'False
  332.       EndProperty
  333.       ForeColor       =   &H000000FF&
  334.       Height          =   375
  335.       Left            =   6480
  336.       TabIndex        =   25
  337.       Top             =   240
  338.       Width           =   975
  339.    End
  340.    Begin VB.Line Line1 
  341.       X1              =   120
  342.       X2              =   7680
  343.       Y1              =   4800
  344.       Y2              =   4800
  345.    End
  346. Attribute VB_Name = "WalkXMLDlg"
  347. Attribute VB_GlobalNameSpace = False
  348. Attribute VB_Creatable = False
  349. Attribute VB_PredeclaredId = True
  350. Attribute VB_Exposed = False
  351. Public objWalkDoc As XMLSpyDocument
  352. Dim objCurrentParent As XMLSpyXMLData
  353. Dim objCurrentChild As XMLSpyXMLData
  354. Dim nRet As Integer
  355. Dim WithEvents objGrid As XMLSpyGridView
  356. Attribute objGrid.VB_VarHelpID = -1
  357. Option Explicit
  358. Private Sub BtnAppend_Click()
  359.     On Error Resume Next
  360.     Dim objNewChild As XMLSpyXMLData
  361.     Set objNewChild = objWalkDoc.CreateChild(spyXMLDataElement)
  362.     objCurrentParent.appendChild objNewChild
  363.     CheckForError
  364.     Set objNewChild = Nothing
  365. End Sub
  366. Private Sub BtnEnd_Click()
  367.     objWalkDoc.EndChanges
  368.     TxtUpdate.Caption = "updates"
  369. End Sub
  370. Private Sub BtnErase_Click()
  371.     'EraseCurrentChild steps to next child
  372.     'nRet = objWalkDoc.GridView.Deselect(objCurrentChild)
  373.     On Error Resume Next
  374.     objCurrentParent.EraseCurrentChild
  375.     CheckForError
  376.     objCurrentChild = objCurrentParent.GetCurrentChild
  377.     CheckForError
  378. End Sub
  379. Private Sub BtnEraseAll_Click()
  380.     'erase all children
  381.     On Error Resume Next
  382.     objWalkDoc.GridView.Deselect objCurrentChild
  383.     CheckForError
  384.     objCurrentParent.EraseAllChildren
  385.     CheckForError
  386.     'set new parent and child
  387.     Set objCurrentParent = objCurrentParent.Parent
  388.     On Error GoTo ErrorHandler
  389.     Set objCurrentChild = objCurrentParent.GetFirstChild(-1)
  390.     UpdateEdits
  391.     EnableBtnStepDown
  392.     objWalkDoc.GridView.Select objCurrentChild
  393.     Exit Sub
  394. ErrorHandler:
  395.     Set objCurrentParent = objWalkDoc.RootElement
  396.     Set objCurrentChild = objCurrentParent.GetFirstChild(-1, nRet)
  397.     UpdateEdits
  398.     EnableBtnStepDown
  399. End Sub
  400. Private Sub BtnInsert_Click()
  401.     Dim objNewChild As XMLSpyXMLData
  402.     Set objNewChild = objWalkDoc.CreateChild(spyXMLDataElement)
  403.     On Error Resume Next
  404.     objCurrentParent.InsertChild objNewChild
  405.     CheckForError
  406.     Set objNewChild = Nothing
  407. End Sub
  408. Private Sub BtnNextChild_Click()
  409.     On Error GoTo ErrorHandler
  410.     objWalkDoc.GridView.Deselect objCurrentChild
  411.     Set objCurrentChild = objCurrentParent.GetNextChild
  412.     UpdateEdits
  413.     objWalkDoc.GridView.Select objCurrentChild
  414.     EnableBtnStepDown
  415.     Exit Sub
  416. ErrorHandler:
  417.     CheckForError
  418. End Sub
  419. Private Sub BtnParent_Click()
  420.     Set objCurrentParent = objCurrentParent.Parent
  421.     On Error GoTo ErrorHandler
  422.     objWalkDoc.GridView.Deselect objCurrentChild
  423.     Set objCurrentChild = objCurrentParent.GetFirstChild(-1)
  424.     UpdateEdits
  425.     EnableBtnStepDown
  426.     objWalkDoc.GridView.Select objCurrentChild
  427.     Exit Sub
  428. ErrorHandler:
  429.     CheckForError
  430.     Set objCurrentParent = objWalkDoc.RootElement
  431.     Set objCurrentChild = objCurrentParent.GetFirstChild(-1, nRet)
  432.     UpdateEdits
  433.     EnableBtnStepDown
  434. End Sub
  435. Private Sub BtnSetFocus_Click()
  436.     objWalkDoc.GridView.SetFocus objCurrentChild
  437.     UpdateEdits
  438. End Sub
  439. Private Sub BtnStart_Click()
  440.     objWalkDoc.StartChanges
  441.     TxtUpdate.Caption = "no" & Chr(13) & "updates"
  442. End Sub
  443. Private Sub BtnStepDown_Click()
  444.     If objCurrentChild.HasChildren Then
  445.         objWalkDoc.GridView.Deselect objCurrentChild
  446.         Set objCurrentParent = objCurrentChild
  447.         Set objCurrentChild = objCurrentParent.GetFirstChild(-1)
  448.         UpdateEdits
  449.         objWalkDoc.GridView.Select objCurrentChild
  450.     End If
  451.     EnableBtnStepDown
  452. End Sub
  453. Private Sub EditNameChild_Change()
  454.     objCurrentChild.Name = EditNameChild.Text
  455.     objWalkDoc.UpdateViews
  456. End Sub
  457. Private Sub EditValueChild_Change()
  458.     objCurrentChild.TextValue = EditValueChild.Text
  459.     objWalkDoc.UpdateViews
  460. End Sub
  461. Private Sub Form_Activate()
  462.     On Error GoTo ErrorHandler
  463.     Set objCurrentParent = objWalkDoc.RootElement
  464.     Set objCurrentChild = objCurrentParent.GetFirstChild(-1)
  465.     UpdateEdits
  466.     EnableBtnStepDown
  467.     objWalkDoc.GridView.Select objCurrentChild
  468.     Set objGrid = objWalkDoc.GridView
  469.     Exit Sub
  470. ErrorHandler:
  471.     Dim a As Integer
  472.     a = MsgBox("Fehler beim 
  473. ffnen des XMLData-Dialogs. Vielleicht ist kein Document ge
  474. ffnet!")
  475.     Unload Me
  476. End Sub
  477. Private Sub EnableBtnStepDown()
  478.     BtnStepDown.Enabled = False
  479.     On Error GoTo ErrorHandler
  480.     If objCurrentChild.HasChildren Then
  481.         BtnStepDown.Enabled = True
  482.     End If
  483.     Exit Sub
  484. ErrorHandler:
  485. End Sub
  486. Private Sub UpdateEdits()
  487.     On Error GoTo ErrorHandler
  488.     EditKindChild.Text = GetNameOfKind(objCurrentChild.Kind)
  489.     EditNameChild.Text = objCurrentChild.Name
  490.     EditValueChild.Text = objCurrentChild.TextValue
  491.     EditKind.Text = GetNameOfKind(objCurrentParent.Kind)
  492.     EditName.Text = objCurrentParent.Name
  493.     EditValue.Text = objCurrentParent.TextValue
  494.     EditFocusKind.Text = GetNameOfKind(objWalkDoc.GridView.CurrentFocus.Kind)
  495.     EditFocusName.Text = objWalkDoc.GridView.CurrentFocus.Name
  496.     EditFocusValue.Text = objWalkDoc.GridView.CurrentFocus.TextValue
  497.     TxtMayChildren.Caption = "may have children"
  498.     If (objCurrentChild.MayHaveChildren = False) Then
  499.         TxtMayChildren.Caption = "can't have children"
  500.     End If
  501.     Exit Sub
  502. ErrorHandler:
  503. End Sub
  504. Private Sub objGrid_OnFocusChanged(ByVal pXMLData As XMLSpyLib.XMLSpyXMLData, ByVal bFocusSet As Boolean)
  505.     If bFocusSet Then
  506.         UpdateEdits
  507.     End If
  508. End Sub
  509. Private Sub OKButton_Click()
  510.     Unload Me
  511. End Sub
  512.