home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 3_2004-2005.ISO / Data / Zips / API-ucTree1887955132005.psc / Test.frm < prev    next >
Text File  |  2004-10-27  |  28KB  |  935 lines

  1. VERSION 5.00
  2. Begin VB.Form fTest 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "ucTreeVew 1.2 - Test"
  5.    ClientHeight    =   8025
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   10020
  9.    BeginProperty Font 
  10.       Name            =   "Tahoma"
  11.       Size            =   8.25
  12.       Charset         =   0
  13.       Weight          =   400
  14.       Underline       =   0   'False
  15.       Italic          =   0   'False
  16.       Strikethrough   =   0   'False
  17.    EndProperty
  18.    LinkTopic       =   "Form1"
  19.    LockControls    =   -1  'True
  20.    MaxButton       =   0   'False
  21.    ScaleHeight     =   535
  22.    ScaleMode       =   3  'Pixel
  23.    ScaleWidth      =   668
  24.    StartUpPosition =   2  'CenterScreen
  25.    Begin Test.ucTreeView ucTreeView1 
  26.       Height          =   7725
  27.       Left            =   150
  28.       TabIndex        =   52
  29.       Top             =   135
  30.       Width           =   3885
  31.       _ExtentX        =   6853
  32.       _ExtentY        =   13626
  33.    End
  34.    Begin VB.CheckBox chkEnsureVisible 
  35.       Appearance      =   0  'Flat
  36.       Caption         =   "Ensure visible"
  37.       Height          =   285
  38.       Left            =   4260
  39.       TabIndex        =   24
  40.       Top             =   3930
  41.       Width           =   1425
  42.    End
  43.    Begin VB.CommandButton cmdFirstVisible 
  44.       Caption         =   "First visible"
  45.       Height          =   375
  46.       Left            =   7080
  47.       TabIndex        =   28
  48.       Top             =   3960
  49.       Width           =   1350
  50.    End
  51.    Begin VB.CommandButton cmdLastVisible 
  52.       Caption         =   "Last visible"
  53.       Height          =   375
  54.       Left            =   7080
  55.       TabIndex        =   31
  56.       Top             =   5220
  57.       Width           =   1350
  58.    End
  59.    Begin VB.TextBox txtKey 
  60.       Appearance      =   0  'Flat
  61.       Height          =   285
  62.       Left            =   8805
  63.       MaxLength       =   50
  64.       TabIndex        =   44
  65.       Top             =   6510
  66.       Width           =   1035
  67.    End
  68.    Begin VB.TextBox txthRelative 
  69.       Appearance      =   0  'Flat
  70.       Height          =   285
  71.       Left            =   6870
  72.       MaxLength       =   50
  73.       TabIndex        =   42
  74.       Text            =   "0"
  75.       Top             =   6510
  76.       Width           =   1035
  77.    End
  78.    Begin VB.OptionButton optRelation 
  79.       Appearance      =   0  'Flat
  80.       Caption         =   "Previous"
  81.       Height          =   285
  82.       Index           =   4
  83.       Left            =   8970
  84.       TabIndex        =   49
  85.       Top             =   7095
  86.       Width           =   975
  87.    End
  88.    Begin VB.OptionButton optRelation 
  89.       Appearance      =   0  'Flat
  90.       Caption         =   "Next"
  91.       Height          =   285
  92.       Index           =   3
  93.       Left            =   8250
  94.       TabIndex        =   48
  95.       Top             =   7095
  96.       Width           =   975
  97.    End
  98.    Begin VB.OptionButton optRelation 
  99.       Appearance      =   0  'Flat
  100.       Caption         =   "Sorted"
  101.       Height          =   285
  102.       Index           =   2
  103.       Left            =   7395
  104.       TabIndex        =   3
  105.       Top             =   7095
  106.       Width           =   975
  107.    End
  108.    Begin VB.OptionButton optRelation 
  109.       Appearance      =   0  'Flat
  110.       Caption         =   "First"
  111.       Height          =   285
  112.       Index           =   1
  113.       Left            =   6720
  114.       TabIndex        =   47
  115.       Top             =   7095
  116.       Width           =   975
  117.    End
  118.    Begin VB.OptionButton optRelation 
  119.       Appearance      =   0  'Flat
  120.       Caption         =   "Last"
  121.       Height          =   285
  122.       Index           =   0
  123.       Left            =   6060
  124.       TabIndex        =   46
  125.       Top             =   7095
  126.       Value           =   -1  'True
  127.       Width           =   765
  128.    End
  129.    Begin VB.CommandButton cmdInsert 
  130.       Caption         =   "Insert"
  131.       Height          =   375
  132.       Left            =   7230
  133.       TabIndex        =   50
  134.       Top             =   7485
  135.       Width           =   1350
  136.    End
  137.    Begin VB.CommandButton cmdDeleteCurrent 
  138.       Caption         =   "Delete current"
  139.       Height          =   375
  140.       Left            =   4260
  141.       TabIndex        =   39
  142.       Top             =   7485
  143.       Width           =   1350
  144.    End
  145.    Begin VB.TextBox txtText 
  146.       Appearance      =   0  'Flat
  147.       Height          =   285
  148.       Left            =   4740
  149.       MaxLength       =   50
  150.       TabIndex        =   19
  151.       Top             =   3135
  152.       Width           =   2235
  153.    End
  154.    Begin VB.CheckBox chkLabelEdit 
  155.       Appearance      =   0  'Flat
  156.       Caption         =   "LabelEdit"
  157.       Height          =   285
  158.       Left            =   7035
  159.       TabIndex        =   6
  160.       Top             =   450
  161.       Width           =   2820
  162.    End
  163.    Begin VB.CheckBox chkFullRowSelect 
  164.       Appearance      =   0  'Flat
  165.       Caption         =   "FullRowSelect"
  166.       Height          =   285
  167.       Left            =   7035
  168.       TabIndex        =   10
  169.       Top             =   1590
  170.       Width           =   2820
  171.    End
  172.    Begin VB.CheckBox chkHideSelection 
  173.       Appearance      =   0  'Flat
  174.       Caption         =   "HideSelection"
  175.       Height          =   285
  176.       Left            =   7035
  177.       TabIndex        =   7
  178.       Top             =   735
  179.       Width           =   2820
  180.    End
  181.    Begin VB.CheckBox chkSingleExpand 
  182.       Appearance      =   0  'Flat
  183.       Caption         =   "SingleExpand (+[Ctl]: no collapse)"
  184.       Height          =   285
  185.       Left            =   7035
  186.       TabIndex        =   8
  187.       Top             =   1020
  188.       Width           =   2820
  189.    End
  190.    Begin VB.CheckBox chkTrackSelect 
  191.       Appearance      =   0  'Flat
  192.       Caption         =   "TrackSelect"
  193.       Height          =   285
  194.       Left            =   7035
  195.       TabIndex        =   9
  196.       Top             =   1305
  197.       Width           =   2820
  198.    End
  199.    Begin VB.CheckBox chkHilited 
  200.       Appearance      =   0  'Flat
  201.       Caption         =   "Hilited"
  202.       Height          =   285
  203.       Left            =   9150
  204.       TabIndex        =   22
  205.       Top             =   3135
  206.       Width           =   990
  207.    End
  208.    Begin VB.CheckBox chkGhosted 
  209.       Appearance      =   0  'Flat
  210.       Caption         =   "Ghosted"
  211.       Height          =   285
  212.       Left            =   8115
  213.       TabIndex        =   21
  214.       Top             =   3135
  215.       Width           =   990
  216.    End
  217.    Begin VB.CheckBox chkBold 
  218.       Appearance      =   0  'Flat
  219.       Caption         =   "Bold"
  220.       Height          =   285
  221.       Left            =   7380
  222.       TabIndex        =   20
  223.       Top             =   3135
  224.       Width           =   960
  225.    End
  226.    Begin VB.CommandButton cmdClear 
  227.       Caption         =   "Clear"
  228.       Height          =   375
  229.       Left            =   4260
  230.       TabIndex        =   38
  231.       Top             =   6615
  232.       Width           =   1350
  233.    End
  234.    Begin VB.CheckBox chkHasRootLines 
  235.       Appearance      =   0  'Flat
  236.       Caption         =   "HasRootLines"
  237.       Enabled         =   0   'False
  238.       Height          =   285
  239.       Left            =   4260
  240.       TabIndex        =   2
  241.       Top             =   735
  242.       Width           =   2820
  243.    End
  244.    Begin VB.CheckBox chkCheckBoxes 
  245.       Appearance      =   0  'Flat
  246.       Caption         =   "CheckBoxes*"
  247.       Height          =   285
  248.       Left            =   4260
  249.       TabIndex        =   5
  250.       Top             =   1305
  251.       Width           =   2820
  252.    End
  253.    Begin VB.CheckBox chkHasLines 
  254.       Appearance      =   0  'Flat
  255.       Caption         =   "HasLines"
  256.       Height          =   285
  257.       Left            =   4260
  258.       TabIndex        =   1
  259.       Top             =   450
  260.       Width           =   2820
  261.    End
  262.    Begin VB.CheckBox chkHasButtons 
  263.       Appearance      =   0  'Flat
  264.       Caption         =   "HasButtons (plus/minus buttons)"
  265.       Height          =   285
  266.       Left            =   4260
  267.       TabIndex        =   4
  268.       Top             =   1020
  269.       Width           =   2820
  270.    End
  271.    Begin VB.CommandButton cmdLastSibling 
  272.       Caption         =   "Last sibling"
  273.       Height          =   375
  274.       Left            =   8490
  275.       TabIndex        =   35
  276.       Top             =   5220
  277.       Width           =   1350
  278.    End
  279.    Begin VB.CommandButton cmdNextSibling 
  280.       Caption         =   "Next sibling"
  281.       Height          =   375
  282.       Left            =   8490
  283.       TabIndex        =   34
  284.       Top             =   4800
  285.       Width           =   1350
  286.    End
  287.    Begin VB.CommandButton cmdPreviousSibling 
  288.       Caption         =   "Previous sibling"
  289.       Height          =   375
  290.       Left            =   8490
  291.       TabIndex        =   33
  292.       Top             =   4380
  293.       Width           =   1350
  294.    End
  295.    Begin VB.CommandButton cmdFirstSibling 
  296.       Caption         =   "First sibling"
  297.       Height          =   375
  298.       Left            =   8490
  299.       TabIndex        =   32
  300.       Top             =   3960
  301.       Width           =   1350
  302.    End
  303.    Begin VB.CommandButton cmdRoot 
  304.       Caption         =   "Root"
  305.       Height          =   375
  306.       Left            =   4260
  307.       TabIndex        =   25
  308.       Top             =   4380
  309.       Width           =   1350
  310.    End
  311.    Begin VB.CommandButton cmdChild 
  312.       Caption         =   "Child"
  313.       Height          =   375
  314.       Left            =   5670
  315.       TabIndex        =   27
  316.       Top             =   4800
  317.       Width           =   1350
  318.    End
  319.    Begin VB.CommandButton cmdParent 
  320.       Caption         =   "Parent"
  321.       Height          =   375
  322.       Left            =   5670
  323.       TabIndex        =   26
  324.       Top             =   4380
  325.       Width           =   1350
  326.    End
  327.    Begin VB.CommandButton cmdPrevious 
  328.       Caption         =   "Previous"
  329.       Height          =   375
  330.       Left            =   7080
  331.       TabIndex        =   29
  332.       Top             =   4380
  333.       Width           =   1350
  334.    End
  335.    Begin VB.CommandButton cmdNext 
  336.       Caption         =   "Next"
  337.       Height          =   375
  338.       Left            =   7080
  339.       TabIndex        =   30
  340.       Top             =   4800
  341.       Width           =   1350
  342.    End
  343.    Begin VB.CommandButton cmdFill 
  344.       Caption         =   "Fill/Add"
  345.       Height          =   375
  346.       Left            =   4260
  347.       TabIndex        =   37
  348.       Top             =   6180
  349.       Width           =   1350
  350.    End
  351.    Begin VB.Label lblNote 
  352.       Caption         =   "*TreeView should be created again"
  353.       BeginProperty Font 
  354.          Name            =   "Tahoma"
  355.          Size            =   6.75
  356.          Charset         =   0
  357.          Weight          =   400
  358.          Underline       =   0   'False
  359.          Italic          =   0   'False
  360.          Strikethrough   =   0   'False
  361.       EndProperty
  362.       ForeColor       =   &H80000010&
  363.       Height          =   240
  364.       Left            =   4260
  365.       TabIndex        =   51
  366.       Top             =   1650
  367.       Width           =   2625
  368.    End
  369.    Begin VB.Label Label1 
  370.       Caption         =   "Key:"
  371.       Height          =   240
  372.       Left            =   8430
  373.       TabIndex        =   43
  374.       Top             =   6540
  375.       Width           =   360
  376.    End
  377.    Begin VB.Label lblhRelative 
  378.       Caption         =   "hRelative:"
  379.       Height          =   240
  380.       Left            =   6090
  381.       TabIndex        =   41
  382.       Top             =   6540
  383.       Width           =   765
  384.    End
  385.    Begin VB.Label lblRelation 
  386.       Caption         =   "Relation:"
  387.       Height          =   240
  388.       Left            =   6090
  389.       TabIndex        =   45
  390.       Top             =   6870
  391.       Width           =   765
  392.    End
  393.    Begin VB.Label lblInsertNode 
  394.       BackColor       =   &H80000010&
  395.       Caption         =   " Insert node"
  396.       BeginProperty Font 
  397.          Name            =   "Tahoma"
  398.          Size            =   8.25
  399.          Charset         =   0
  400.          Weight          =   700
  401.          Underline       =   0   'False
  402.          Italic          =   0   'False
  403.          Strikethrough   =   0   'False
  404.       EndProperty
  405.       ForeColor       =   &H80000014&
  406.       Height          =   225
  407.       Left            =   6075
  408.       TabIndex        =   40
  409.       Top             =   6180
  410.       Width           =   3765
  411.    End
  412.    Begin VB.Label lblAddingDeletingNodes 
  413.       BackColor       =   &H80000010&
  414.       Caption         =   " Adding/deleting nodes:"
  415.       BeginProperty Font 
  416.          Name            =   "Tahoma"
  417.          Size            =   8.25
  418.          Charset         =   0
  419.          Weight          =   700
  420.          Underline       =   0   'False
  421.          Italic          =   0   'False
  422.          Strikethrough   =   0   'False
  423.       EndProperty
  424.       ForeColor       =   &H80000014&
  425.       Height          =   225
  426.       Left            =   4260
  427.       TabIndex        =   36
  428.       Top             =   5730
  429.       Width           =   5580
  430.    End
  431.    Begin VB.Label lblNodeNavigation 
  432.       BackColor       =   &H80000010&
  433.       Caption         =   " Node navigation:"
  434.       BeginProperty Font 
  435.          Name            =   "Tahoma"
  436.          Size            =   8.25
  437.          Charset         =   0
  438.          Weight          =   700
  439.          Underline       =   0   'False
  440.          Italic          =   0   'False
  441.          Strikethrough   =   0   'False
  442.       EndProperty
  443.       ForeColor       =   &H80000014&
  444.       Height          =   225
  445.       Left            =   4260
  446.       TabIndex        =   23
  447.       Top             =   3600
  448.       Width           =   5580
  449.    End
  450.    Begin VB.Label lblText 
  451.       Caption         =   "Text:"
  452.       Height          =   255
  453.       Left            =   4245
  454.       TabIndex        =   18
  455.       Top             =   3165
  456.       Width           =   690
  457.    End
  458.    Begin VB.Label lblTreeViewStyles 
  459.       BackColor       =   &H80000010&
  460.       Caption         =   " TreeView styles:"
  461.       BeginProperty Font 
  462.          Name            =   "Tahoma"
  463.          Size            =   8.25
  464.          Charset         =   0
  465.          Weight          =   700
  466.          Underline       =   0   'False
  467.          Italic          =   0   'False
  468.          Strikethrough   =   0   'False
  469.       EndProperty
  470.       ForeColor       =   &H80000014&
  471.       Height          =   225
  472.       Left            =   4260
  473.       TabIndex        =   0
  474.       Top             =   135
  475.       Width           =   5580
  476.    End
  477.    Begin VB.Label lblKeyVal 
  478.       Height          =   255
  479.       Left            =   5025
  480.       TabIndex        =   15
  481.       Top             =   2565
  482.       Width           =   1455
  483.    End
  484.    Begin VB.Label lblFullPathVal 
  485.       Height          =   225
  486.       Left            =   5025
  487.       TabIndex        =   17
  488.       Top             =   2820
  489.       Width           =   4815
  490.    End
  491.    Begin VB.Label lblhNodeVal 
  492.       Caption         =   "0"
  493.       Height          =   255
  494.       Left            =   5025
  495.       TabIndex        =   13
  496.       Top             =   2310
  497.       Width           =   1455
  498.    End
  499.    Begin VB.Label lblKey 
  500.       Caption         =   "Key:"
  501.       Height          =   255
  502.       Left            =   4260
  503.       TabIndex        =   14
  504.       Top             =   2565
  505.       Width           =   690
  506.    End
  507.    Begin VB.Label lblFullPath 
  508.       Caption         =   "Full path:"
  509.       Height          =   255
  510.       Left            =   4260
  511.       TabIndex        =   16
  512.       Top             =   2820
  513.       Width           =   690
  514.    End
  515.    Begin VB.Label lblhNode 
  516.       Caption         =   "hNode:"
  517.       Height          =   255
  518.       Left            =   4260
  519.       TabIndex        =   12
  520.       Top             =   2310
  521.       Width           =   690
  522.    End
  523.    Begin VB.Label lblCurrentNode 
  524.       BackColor       =   &H80000010&
  525.       Caption         =   " Current node:"
  526.       BeginProperty Font 
  527.          Name            =   "Tahoma"
  528.          Size            =   8.25
  529.          Charset         =   0
  530.          Weight          =   700
  531.          Underline       =   0   'False
  532.          Italic          =   0   'False
  533.          Strikethrough   =   0   'False
  534.       EndProperty
  535.       ForeColor       =   &H80000014&
  536.       Height          =   225
  537.       Left            =   4260
  538.       TabIndex        =   11
  539.       Top             =   1980
  540.       Width           =   5580
  541.    End
  542. End
  543. Attribute VB_Name = "fTest"
  544. Attribute VB_GlobalNameSpace = False
  545. Attribute VB_Creatable = False
  546. Attribute VB_PredeclaredId = True
  547. Attribute VB_Exposed = False
  548. Option Explicit
  549.  
  550. Private Const GWL_STYLE As Long = (-16)
  551. Private Const BS_FLAT   As Long = &H8000&
  552. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
  553. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  554.  
  555.  
  556.  
  557.  
  558.  
  559. Private Sub Form_Load()
  560.  
  561.   Dim oCtl As Control
  562.  
  563.     With ucTreeView1
  564.         
  565.         Call .Initialize
  566.         Call .InitializeImageList 'Default size is 16x16
  567.      
  568.         Call .AddIcon(LoadResPicture(101, vbResIcon))
  569.         Call .AddIcon(LoadResPicture(102, vbResIcon))
  570.         Call .AddIcon(LoadResPicture(103, vbResIcon))
  571.         Call .AddIcon(LoadResPicture(104, vbResIcon))
  572.         Call .AddIcon(LoadResPicture(105, vbResIcon))
  573.         
  574.         .ItemHeight = 18 'Should be even (Set to -1 to restore to default).
  575.         .ItemIndent = 33 '19 is default.
  576.     End With
  577.     
  578.     For Each oCtl In fTest.Controls
  579.         If (TypeOf oCtl Is CommandButton) Then
  580.             Call pvFlattenButton(oCtl.hWnd)
  581.         End If
  582.     Next oCtl
  583. End Sub
  584.  
  585.  
  586.  
  587. '==== TreeView Styles
  588.  
  589. Private Sub chkHasLines_Click()
  590.     ucTreeView1.HasLines = -chkHasLines
  591.     chkHasRootLines.Enabled = chkHasButtons Or chkHasLines
  592.     chkFullRowSelect.Enabled = Not -chkHasLines
  593. End Sub
  594.  
  595. Private Sub chkHasRootLines_Click()
  596.     ucTreeView1.HasRootLines = -chkHasRootLines
  597. End Sub
  598.  
  599. Private Sub chkHasButtons_Click()
  600.     ucTreeView1.HasButtons = -chkHasButtons
  601.     chkHasRootLines.Enabled = chkHasButtons Or chkHasLines
  602. End Sub
  603.  
  604. Private Sub chkCheckBoxes_Click()
  605.     ucTreeView1.CheckBoxes = -chkCheckBoxes
  606. End Sub
  607.  
  608. Private Sub chkLabelEdit_Click()
  609.     ucTreeView1.LabelEdit = -chkLabelEdit
  610. End Sub
  611.  
  612. Private Sub chkHideSelection_Click()
  613.     ucTreeView1.HideSelection = -chkHideSelection
  614. End Sub
  615.  
  616. Private Sub chkSingleExpand_Click()
  617.     ucTreeView1.SingleExpand = -chkSingleExpand
  618.     chkLabelEdit.Enabled = Not -chkSingleExpand
  619. End Sub
  620.  
  621. Private Sub chkTrackSelect_Click()
  622.     ucTreeView1.TrackSelect = -chkTrackSelect
  623. End Sub
  624.  
  625. Private Sub chkFullRowSelect_Click()
  626.     ucTreeView1.FullRowSelect = -chkFullRowSelect
  627. End Sub
  628.  
  629.  
  630.  
  631. '==== Current node
  632.  
  633. Private Sub txtText_Change()
  634.     If (txtText.Tag = vbNullString) Then
  635.         ucTreeView1.NodeText(ucTreeView1.SelectedNode) = txtText.Text
  636.         lblFullPathVal.Caption = ucTreeView1.NodeFullPath(ucTreeView1.SelectedNode)
  637.     End If
  638. End Sub
  639.  
  640. Private Sub chkBold_Click()
  641.     If (chkBold.Tag = vbNullString) Then
  642.         ucTreeView1.NodeBold(ucTreeView1.SelectedNode) = -chkBold
  643.     End If
  644. End Sub
  645.  
  646. Private Sub chkGhosted_Click()
  647.     If (chkGhosted.Tag = vbNullString) Then
  648.         ucTreeView1.NodeGhosted(ucTreeView1.SelectedNode) = -chkGhosted
  649.     End If
  650. End Sub
  651.  
  652. Private Sub chkHilited_Click()
  653.     If (chkHilited.Tag = vbNullString) Then
  654.         ucTreeView1.NodeHilited(ucTreeView1.SelectedNode) = -chkHilited
  655.     End If
  656. End Sub
  657.  
  658.  
  659.  
  660. '====  Node relationship
  661.  
  662. Private Sub cmdRoot_Click()
  663.     ucTreeView1.SelectedNode = ucTreeView1.NodeRoot
  664. End Sub
  665.  
  666. Private Sub cmdParent_Click()
  667.     ucTreeView1.SelectedNode = ucTreeView1.NodeParent(ucTreeView1.SelectedNode)
  668. End Sub
  669. Private Sub cmdChild_Click()
  670.     ucTreeView1.SelectedNode = ucTreeView1.NodeChild(ucTreeView1.SelectedNode)
  671. End Sub
  672.  
  673. Private Sub cmdFirstVisible_Click()
  674.     ucTreeView1.SelectedNode = ucTreeView1.NodeFirstVisible()
  675. End Sub
  676. Private Sub cmdPrevious_Click()
  677.     ucTreeView1.SelectedNode = ucTreeView1.NodePrevious(ucTreeView1.SelectedNode)
  678. End Sub
  679. Private Sub cmdNext_Click()
  680.     ucTreeView1.SelectedNode = ucTreeView1.NodeNext(ucTreeView1.SelectedNode)
  681. End Sub
  682. Private Sub cmdLastVisible_Click()
  683.     ucTreeView1.SelectedNode = ucTreeView1.NodeLastVisible()
  684. End Sub
  685.  
  686. Private Sub cmdFirstSibling_Click()
  687.     ucTreeView1.SelectedNode = ucTreeView1.NodeFirstSibling(ucTreeView1.SelectedNode)
  688. End Sub
  689. Private Sub cmdPreviousSibling_Click()
  690.     ucTreeView1.SelectedNode = ucTreeView1.NodePreviousSibling(ucTreeView1.SelectedNode)
  691. End Sub
  692. Private Sub cmdNextSibling_Click()
  693.     ucTreeView1.SelectedNode = ucTreeView1.NodeNextSibling(ucTreeView1.SelectedNode)
  694. End Sub
  695. Private Sub cmdLastSibling_Click()
  696.     ucTreeView1.SelectedNode = ucTreeView1.NodeLastSibling(ucTreeView1.SelectedNode)
  697. End Sub
  698.  
  699.  
  700.  
  701. '==== Adding/deleting nodes
  702.  
  703. Private Sub cmdFill_Click()
  704.   
  705.   Static lcBook As Long
  706.   Static lKey   As Long
  707.   
  708.   Dim lC   As Long
  709.   Dim lP   As Long
  710.   Dim hB   As Long
  711.   Dim hC   As Long
  712.   Dim hP   As Long
  713.     
  714.     With ucTreeView1
  715.         
  716.         If (.NodeCount > 10000) Then
  717.             Call MsgBox("Stop adding more nodes, please." & vbCrLf & vbCrLf & _
  718.                         "Current node count: " & .NodeCount, vbExclamation)
  719.             Exit Sub
  720.         End If
  721.  
  722.         lcBook = lcBook + 1
  723.         
  724.         Call .SetRedrawMode(Enable:=False)
  725.         
  726.         lKey = lKey + 1
  727.         hB = .AddNode(, , "K" & lKey, "Book #" & lcBook, 0, 1)
  728.         
  729.         For lC = 1 To 20
  730.             lKey = lKey + 1
  731.             hC = .AddNode(hB, , "K" & lKey, "Chapter #" & lC, 0, 1)
  732.             For lP = 1 To 10
  733.                 lKey = lKey + 1
  734.                 hP = .AddNode(hC, , "K" & lKey, "Page #" & lP, 2, 2)
  735.                 lKey = lKey + 1
  736.                 Call .AddNode(hP, , "K" & lKey, "Note #1", 3, 3)
  737.                 lKey = lKey + 1
  738.                 Call .AddNode(hP, , "K" & lKey, "Note #2", 3, 3)
  739.         Next lP, lC
  740.         
  741.         Call .Expand(hB)
  742.         Call .SetRedrawMode(Enable:=True)
  743.         
  744.         Call .Scroll([sEnd])
  745.     End With
  746. End Sub
  747.  
  748. Private Sub cmdClear_Click()
  749.     
  750.     With ucTreeView1
  751.         Call .SetRedrawMode(False)
  752.         Call .Clear
  753.         Call .SetRedrawMode(True)
  754.     End With
  755.     
  756.     Call pvClearInfo
  757. End Sub
  758.  
  759. Private Sub cmdDeleteCurrent_Click()
  760.     
  761.     With ucTreeView1
  762.         Call .SetRedrawMode(False)
  763. '       Call .HoldDeletePostProcess(True)  '(*)
  764.         Call .DeleteNode(.SelectedNode)
  765. '       Call .HoldDeletePostProcess(False) '(*)
  766.         Call .SetRedrawMode(True)
  767.         
  768.         If (.NodeCount = 0) Then
  769.             Call pvClearInfo
  770.         End If
  771.     End With
  772.     
  773. '(*) See ucTreeView.HoldDeletePostProcess() sub note!
  774. End Sub
  775.  
  776. Private Sub cmdInsert_Click()
  777.   
  778.   Static lInsert As Long
  779.   Dim eRelation  As Long
  780.   Dim hNode      As Long
  781.   
  782.     lInsert = lInsert + 1
  783.  
  784.     Select Case True
  785.         Case optRelation(0): eRelation = [rLast]
  786.         Case optRelation(1): eRelation = [rFirst]
  787.         Case optRelation(2): eRelation = [rSort]
  788.         Case optRelation(3): eRelation = [rNext]
  789.         Case optRelation(4): eRelation = [rPrevious]
  790.     End Select
  791.  
  792.     With ucTreeView1
  793.         hNode = .AddNode(Val(txthRelative.Text), eRelation, txtKey.Text, "Inserted node #" & lInsert, 4, 4)
  794.         If (hNode) Then
  795.             Call .EnsureVisible(hNode)
  796.           Else
  797.             Call MsgBox("Key already exists or unexpected error inserting node.", vbExclamation)
  798.         End If
  799.     End With
  800. End Sub
  801.  
  802.  
  803. '==== Raising events (See Debug window)
  804.  
  805. Private Sub ucTreeView1_GotFocus()
  806.     Debug.Print "ucTreeView1_GotFocus"
  807. End Sub
  808. Private Sub ucTreeView1_LostFocus()
  809.     Debug.Print "ucTreeView1_LostFocus"
  810. End Sub
  811.  
  812. Private Sub ucTreeView1_Click()
  813.     Debug.Print "ucTreeView1_Click"
  814. End Sub
  815.  
  816. Private Sub ucTreeView1_BeforeLabelEdit(ByVal hNode As Long, Cancel As Integer)
  817.     Debug.Print "ucTreeView1_BeforeLabelEdit"; hNode; Cancel
  818. End Sub
  819. Private Sub ucTreeView1_AfterLabelEdit(ByVal hNode As Long, Cancel As Integer, NewString As String)
  820.     Debug.Print "ucTreeView1_AfterLabelEdit"; hNode; Cancel; NewString
  821.     
  822.     If (NewString <> vbNullString) Then
  823.         ucTreeView1.NodeText(ucTreeView1.SelectedNode) = NewString
  824.         Call ucTreeView1_NodeClick(ucTreeView1.SelectedNode)
  825.     End If
  826. End Sub
  827.  
  828. Private Sub ucTreeView1_SelectionChanged()
  829.     Debug.Print "ucTreeView1_SelectionChanged"
  830.     
  831.     If (chkEnsureVisible) Then
  832.         Call ucTreeView1.EnsureVisible(ucTreeView1.SelectedNode)
  833.     End If
  834. End Sub
  835. Private Sub ucTreeView1_Collapse(ByVal hNode As Long)
  836.     Debug.Print "ucTreeView1_Collapse"; hNode
  837. End Sub
  838. Private Sub ucTreeView1_ExpandBefore(ByVal hNode As Long, ByVal ExpandedOnce As Boolean)
  839.     Debug.Print "ucTreeView1_ExpandBefore"; hNode; ExpandedOnce
  840. End Sub
  841. Private Sub ucTreeView1_ExpandAfter(ByVal hNode As Long, ByVal ExpandedOnce As Boolean)
  842.     Debug.Print "ucTreeView1_ExpandAfter"; hNode; ExpandedOnce
  843. End Sub
  844.  
  845. Private Sub ucTreeView1_KeyDown(KeyCode As Integer, Shift As Integer)
  846.     Debug.Print "ucTreeView1_KeyDown"; KeyCode; Shift
  847. End Sub
  848. Private Sub ucTreeView1_KeyPress(KeyAscii As Integer)
  849.     Debug.Print "ucTreeView1_KeyPress"; KeyAscii
  850. End Sub
  851. Private Sub ucTreeView1_KeyUp(KeyCode As Integer, Shift As Integer)
  852.     Debug.Print "ucTreeView1_KeyUp"; KeyCode; Shift
  853. End Sub
  854.  
  855. Private Sub ucTreeView1_MouseEnter()
  856.     Debug.Print "ucTreeView1_MouseEnter"
  857. End Sub
  858. Private Sub ucTreeView1_MouseLeave()
  859.     Debug.Print "ucTreeView1_MouseLeave"
  860. End Sub
  861.  
  862. Private Sub ucTreeView1_MouseDown(Button As Integer, Shift As Integer, x As Long, y As Long)
  863.     Debug.Print "ucTreeView1_MouseDown"; Button; Shift; x; y
  864. End Sub
  865. Private Sub ucTreeView1_MouseMove(Button As Integer, Shift As Integer, x As Long, y As Long)
  866. '   Debug.Print "ucTreeView1_MouseMove"; Button; Shift; x; y
  867. End Sub
  868. Private Sub ucTreeView1_MouseUp(Button As Integer, Shift As Integer, x As Long, y As Long)
  869.     Debug.Print "ucTreeView1_MouseUp"; Button; Shift; x; y
  870. End Sub
  871.  
  872. Private Sub ucTreeView1_NodeClick(ByVal hNode As Long)
  873.     Debug.Print "ucTreeView1_NodeClick - hNode = "; hNode
  874.     
  875.     lblhNodeVal.Caption = hNode
  876.     lblKeyVal.Caption = ucTreeView1.GetNodeKey(hNode)
  877.     lblFullPathVal.Caption = ucTreeView1.NodeFullPath(hNode)
  878.     
  879.     chkBold.Tag = 1
  880.         chkBold.Value = -ucTreeView1.NodeBold(hNode)
  881.     chkBold.Tag = vbNullString
  882.     
  883.     chkGhosted.Tag = 1
  884.         chkGhosted.Value = -ucTreeView1.NodeGhosted(hNode)
  885.     chkGhosted.Tag = vbNullString
  886.     
  887.     chkHilited.Tag = 1
  888.         chkHilited.Value = -ucTreeView1.NodeHilited(hNode)
  889.     chkHilited.Tag = vbNullString
  890.     
  891.     txtText.Tag = 1
  892.         txtText.Text = ucTreeView1.NodeText(hNode)
  893.     txtText.Tag = vbNullString
  894.     
  895.     txthRelative.Text = lblhNodeVal.Caption
  896. End Sub
  897. Private Sub ucTreeView1_NodeCheck(ByVal hNode As Long)
  898.     Debug.Print "ucTreeView1_NodeCheck - hNode = "; hNode
  899. End Sub
  900. Private Sub ucTreeView1_NodeDblClick(ByVal hNode As Long)
  901.     Debug.Print "ucTreeView1_NodeDblClick - hNode = "; hNode
  902. End Sub
  903.  
  904. Private Sub ucTreeView1_Resize()
  905. '   Debug.Print "ucTreeView1_Resize"
  906. End Sub
  907.  
  908.  
  909.  
  910.  
  911.  
  912. '==== Misc.
  913.  
  914. Private Sub pvClearInfo()
  915.     
  916.     lblhNodeVal.Caption = "0"
  917.     lblKeyVal.Caption = vbNullString
  918.     lblFullPathVal.Caption = vbNullString
  919.     
  920.     chkBold.Value = 0
  921.     chkGhosted.Value = 0
  922.     chkHilited.Value = 0
  923.     txtText.Text = vbNullString
  924.     
  925.     txthRelative.Text = lblhNodeVal.Caption
  926. End Sub
  927.  
  928. Private Sub pvFlattenButton(ByVal hButton As Long)
  929.     
  930.   Dim lS As Long
  931.  
  932.     lS = GetWindowLong(hButton, GWL_STYLE)
  933.     Call SetWindowLong(hButton, GWL_STYLE, lS Or BS_FLAT)
  934. End Sub
  935.