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 (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2004-10-27  |  27.6 KB  |  849 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. Attribute VB_Name = "fTest"
  543. Attribute VB_GlobalNameSpace = False
  544. Attribute VB_Creatable = False
  545. Attribute VB_PredeclaredId = True
  546. Attribute VB_Exposed = False
  547. Option Explicit
  548. Private Const GWL_STYLE As Long = (-16)
  549. Private Const BS_FLAT   As Long = &H8000&
  550. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
  551. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  552. Private Sub Form_Load()
  553.   Dim oCtl As Control
  554.     With ucTreeView1
  555.         
  556.         Call .Initialize
  557.         Call .InitializeImageList 'Default size is 16x16
  558.      
  559.         Call .AddIcon(LoadResPicture(101, vbResIcon))
  560.         Call .AddIcon(LoadResPicture(102, vbResIcon))
  561.         Call .AddIcon(LoadResPicture(103, vbResIcon))
  562.         Call .AddIcon(LoadResPicture(104, vbResIcon))
  563.         Call .AddIcon(LoadResPicture(105, vbResIcon))
  564.         
  565.         .ItemHeight = 18 'Should be even (Set to -1 to restore to default).
  566.         .ItemIndent = 33 '19 is default.
  567.     End With
  568.     For Each oCtl In fTest.Controls
  569.         If (TypeOf oCtl Is CommandButton) Then
  570.             Call pvFlattenButton(oCtl.hWnd)
  571.         End If
  572.     Next oCtl
  573. End Sub
  574. '==== TreeView Styles
  575. Private Sub chkHasLines_Click()
  576.     ucTreeView1.HasLines = -chkHasLines
  577.     chkHasRootLines.Enabled = chkHasButtons Or chkHasLines
  578.     chkFullRowSelect.Enabled = Not -chkHasLines
  579. End Sub
  580. Private Sub chkHasRootLines_Click()
  581.     ucTreeView1.HasRootLines = -chkHasRootLines
  582. End Sub
  583. Private Sub chkHasButtons_Click()
  584.     ucTreeView1.HasButtons = -chkHasButtons
  585.     chkHasRootLines.Enabled = chkHasButtons Or chkHasLines
  586. End Sub
  587. Private Sub chkCheckBoxes_Click()
  588.     ucTreeView1.CheckBoxes = -chkCheckBoxes
  589. End Sub
  590. Private Sub chkLabelEdit_Click()
  591.     ucTreeView1.LabelEdit = -chkLabelEdit
  592. End Sub
  593. Private Sub chkHideSelection_Click()
  594.     ucTreeView1.HideSelection = -chkHideSelection
  595. End Sub
  596. Private Sub chkSingleExpand_Click()
  597.     ucTreeView1.SingleExpand = -chkSingleExpand
  598.     chkLabelEdit.Enabled = Not -chkSingleExpand
  599. End Sub
  600. Private Sub chkTrackSelect_Click()
  601.     ucTreeView1.TrackSelect = -chkTrackSelect
  602. End Sub
  603. Private Sub chkFullRowSelect_Click()
  604.     ucTreeView1.FullRowSelect = -chkFullRowSelect
  605. End Sub
  606. '==== Current node
  607. Private Sub txtText_Change()
  608.     If (txtText.Tag = vbNullString) Then
  609.         ucTreeView1.NodeText(ucTreeView1.SelectedNode) = txtText.Text
  610.         lblFullPathVal.Caption = ucTreeView1.NodeFullPath(ucTreeView1.SelectedNode)
  611.     End If
  612. End Sub
  613. Private Sub chkBold_Click()
  614.     If (chkBold.Tag = vbNullString) Then
  615.         ucTreeView1.NodeBold(ucTreeView1.SelectedNode) = -chkBold
  616.     End If
  617. End Sub
  618. Private Sub chkGhosted_Click()
  619.     If (chkGhosted.Tag = vbNullString) Then
  620.         ucTreeView1.NodeGhosted(ucTreeView1.SelectedNode) = -chkGhosted
  621.     End If
  622. End Sub
  623. Private Sub chkHilited_Click()
  624.     If (chkHilited.Tag = vbNullString) Then
  625.         ucTreeView1.NodeHilited(ucTreeView1.SelectedNode) = -chkHilited
  626.     End If
  627. End Sub
  628. '====  Node relationship
  629. Private Sub cmdRoot_Click()
  630.     ucTreeView1.SelectedNode = ucTreeView1.NodeRoot
  631. End Sub
  632. Private Sub cmdParent_Click()
  633.     ucTreeView1.SelectedNode = ucTreeView1.NodeParent(ucTreeView1.SelectedNode)
  634. End Sub
  635. Private Sub cmdChild_Click()
  636.     ucTreeView1.SelectedNode = ucTreeView1.NodeChild(ucTreeView1.SelectedNode)
  637. End Sub
  638. Private Sub cmdFirstVisible_Click()
  639.     ucTreeView1.SelectedNode = ucTreeView1.NodeFirstVisible()
  640. End Sub
  641. Private Sub cmdPrevious_Click()
  642.     ucTreeView1.SelectedNode = ucTreeView1.NodePrevious(ucTreeView1.SelectedNode)
  643. End Sub
  644. Private Sub cmdNext_Click()
  645.     ucTreeView1.SelectedNode = ucTreeView1.NodeNext(ucTreeView1.SelectedNode)
  646. End Sub
  647. Private Sub cmdLastVisible_Click()
  648.     ucTreeView1.SelectedNode = ucTreeView1.NodeLastVisible()
  649. End Sub
  650. Private Sub cmdFirstSibling_Click()
  651.     ucTreeView1.SelectedNode = ucTreeView1.NodeFirstSibling(ucTreeView1.SelectedNode)
  652. End Sub
  653. Private Sub cmdPreviousSibling_Click()
  654.     ucTreeView1.SelectedNode = ucTreeView1.NodePreviousSibling(ucTreeView1.SelectedNode)
  655. End Sub
  656. Private Sub cmdNextSibling_Click()
  657.     ucTreeView1.SelectedNode = ucTreeView1.NodeNextSibling(ucTreeView1.SelectedNode)
  658. End Sub
  659. Private Sub cmdLastSibling_Click()
  660.     ucTreeView1.SelectedNode = ucTreeView1.NodeLastSibling(ucTreeView1.SelectedNode)
  661. End Sub
  662. '==== Adding/deleting nodes
  663. Private Sub cmdFill_Click()
  664.   Static lcBook As Long
  665.   Static lKey   As Long
  666.   Dim lC   As Long
  667.   Dim lP   As Long
  668.   Dim hB   As Long
  669.   Dim hC   As Long
  670.   Dim hP   As Long
  671.     With ucTreeView1
  672.         
  673.         If (.NodeCount > 10000) Then
  674.             Call MsgBox("Stop adding more nodes, please." & vbCrLf & vbCrLf & _
  675.                         "Current node count: " & .NodeCount, vbExclamation)
  676.             Exit Sub
  677.         End If
  678.         lcBook = lcBook + 1
  679.         
  680.         Call .SetRedrawMode(Enable:=False)
  681.         
  682.         lKey = lKey + 1
  683.         hB = .AddNode(, , "K" & lKey, "Book #" & lcBook, 0, 1)
  684.         
  685.         For lC = 1 To 20
  686.             lKey = lKey + 1
  687.             hC = .AddNode(hB, , "K" & lKey, "Chapter #" & lC, 0, 1)
  688.             For lP = 1 To 10
  689.                 lKey = lKey + 1
  690.                 hP = .AddNode(hC, , "K" & lKey, "Page #" & lP, 2, 2)
  691.                 lKey = lKey + 1
  692.                 Call .AddNode(hP, , "K" & lKey, "Note #1", 3, 3)
  693.                 lKey = lKey + 1
  694.                 Call .AddNode(hP, , "K" & lKey, "Note #2", 3, 3)
  695.         Next lP, lC
  696.         
  697.         Call .Expand(hB)
  698.         Call .SetRedrawMode(Enable:=True)
  699.         
  700.         Call .Scroll([sEnd])
  701.     End With
  702. End Sub
  703. Private Sub cmdClear_Click()
  704.     With ucTreeView1
  705.         Call .SetRedrawMode(False)
  706.         Call .Clear
  707.         Call .SetRedrawMode(True)
  708.     End With
  709.     Call pvClearInfo
  710. End Sub
  711. Private Sub cmdDeleteCurrent_Click()
  712.     With ucTreeView1
  713.         Call .SetRedrawMode(False)
  714. '       Call .HoldDeletePostProcess(True)  '(*)
  715.         Call .DeleteNode(.SelectedNode)
  716. '       Call .HoldDeletePostProcess(False) '(*)
  717.         Call .SetRedrawMode(True)
  718.         
  719.         If (.NodeCount = 0) Then
  720.             Call pvClearInfo
  721.         End If
  722.     End With
  723. '(*) See ucTreeView.HoldDeletePostProcess() sub note!
  724. End Sub
  725. Private Sub cmdInsert_Click()
  726.   Static lInsert As Long
  727.   Dim eRelation  As Long
  728.   Dim hNode      As Long
  729.     lInsert = lInsert + 1
  730.     Select Case True
  731.         Case optRelation(0): eRelation = [rLast]
  732.         Case optRelation(1): eRelation = [rFirst]
  733.         Case optRelation(2): eRelation = [rSort]
  734.         Case optRelation(3): eRelation = [rNext]
  735.         Case optRelation(4): eRelation = [rPrevious]
  736.     End Select
  737.     With ucTreeView1
  738.         hNode = .AddNode(Val(txthRelative.Text), eRelation, txtKey.Text, "Inserted node #" & lInsert, 4, 4)
  739.         If (hNode) Then
  740.             Call .EnsureVisible(hNode)
  741.           Else
  742.             Call MsgBox("Key already exists or unexpected error inserting node.", vbExclamation)
  743.         End If
  744.     End With
  745. End Sub
  746. '==== Raising events (See Debug window)
  747. Private Sub ucTreeView1_GotFocus()
  748.     Debug.Print "ucTreeView1_GotFocus"
  749. End Sub
  750. Private Sub ucTreeView1_LostFocus()
  751.     Debug.Print "ucTreeView1_LostFocus"
  752. End Sub
  753. Private Sub ucTreeView1_Click()
  754.     Debug.Print "ucTreeView1_Click"
  755. End Sub
  756. Private Sub ucTreeView1_BeforeLabelEdit(ByVal hNode As Long, Cancel As Integer)
  757.     Debug.Print "ucTreeView1_BeforeLabelEdit"; hNode; Cancel
  758. End Sub
  759. Private Sub ucTreeView1_AfterLabelEdit(ByVal hNode As Long, Cancel As Integer, NewString As String)
  760.     Debug.Print "ucTreeView1_AfterLabelEdit"; hNode; Cancel; NewString
  761.     If (NewString <> vbNullString) Then
  762.         ucTreeView1.NodeText(ucTreeView1.SelectedNode) = NewString
  763.         Call ucTreeView1_NodeClick(ucTreeView1.SelectedNode)
  764.     End If
  765. End Sub
  766. Private Sub ucTreeView1_SelectionChanged()
  767.     Debug.Print "ucTreeView1_SelectionChanged"
  768.     If (chkEnsureVisible) Then
  769.         Call ucTreeView1.EnsureVisible(ucTreeView1.SelectedNode)
  770.     End If
  771. End Sub
  772. Private Sub ucTreeView1_Collapse(ByVal hNode As Long)
  773.     Debug.Print "ucTreeView1_Collapse"; hNode
  774. End Sub
  775. Private Sub ucTreeView1_ExpandBefore(ByVal hNode As Long, ByVal ExpandedOnce As Boolean)
  776.     Debug.Print "ucTreeView1_ExpandBefore"; hNode; ExpandedOnce
  777. End Sub
  778. Private Sub ucTreeView1_ExpandAfter(ByVal hNode As Long, ByVal ExpandedOnce As Boolean)
  779.     Debug.Print "ucTreeView1_ExpandAfter"; hNode; ExpandedOnce
  780. End Sub
  781. Private Sub ucTreeView1_KeyDown(KeyCode As Integer, Shift As Integer)
  782.     Debug.Print "ucTreeView1_KeyDown"; KeyCode; Shift
  783. End Sub
  784. Private Sub ucTreeView1_KeyPress(KeyAscii As Integer)
  785.     Debug.Print "ucTreeView1_KeyPress"; KeyAscii
  786. End Sub
  787. Private Sub ucTreeView1_KeyUp(KeyCode As Integer, Shift As Integer)
  788.     Debug.Print "ucTreeView1_KeyUp"; KeyCode; Shift
  789. End Sub
  790. Private Sub ucTreeView1_MouseEnter()
  791.     Debug.Print "ucTreeView1_MouseEnter"
  792. End Sub
  793. Private Sub ucTreeView1_MouseLeave()
  794.     Debug.Print "ucTreeView1_MouseLeave"
  795. End Sub
  796. Private Sub ucTreeView1_MouseDown(Button As Integer, Shift As Integer, x As Long, y As Long)
  797.     Debug.Print "ucTreeView1_MouseDown"; Button; Shift; x; y
  798. End Sub
  799. Private Sub ucTreeView1_MouseMove(Button As Integer, Shift As Integer, x As Long, y As Long)
  800. '   Debug.Print "ucTreeView1_MouseMove"; Button; Shift; x; y
  801. End Sub
  802. Private Sub ucTreeView1_MouseUp(Button As Integer, Shift As Integer, x As Long, y As Long)
  803.     Debug.Print "ucTreeView1_MouseUp"; Button; Shift; x; y
  804. End Sub
  805. Private Sub ucTreeView1_NodeClick(ByVal hNode As Long)
  806.     Debug.Print "ucTreeView1_NodeClick - hNode = "; hNode
  807.     lblhNodeVal.Caption = hNode
  808.     lblKeyVal.Caption = ucTreeView1.GetNodeKey(hNode)
  809.     lblFullPathVal.Caption = ucTreeView1.NodeFullPath(hNode)
  810.     chkBold.Tag = 1
  811.         chkBold.Value = -ucTreeView1.NodeBold(hNode)
  812.     chkBold.Tag = vbNullString
  813.     chkGhosted.Tag = 1
  814.         chkGhosted.Value = -ucTreeView1.NodeGhosted(hNode)
  815.     chkGhosted.Tag = vbNullString
  816.     chkHilited.Tag = 1
  817.         chkHilited.Value = -ucTreeView1.NodeHilited(hNode)
  818.     chkHilited.Tag = vbNullString
  819.     txtText.Tag = 1
  820.         txtText.Text = ucTreeView1.NodeText(hNode)
  821.     txtText.Tag = vbNullString
  822.     txthRelative.Text = lblhNodeVal.Caption
  823. End Sub
  824. Private Sub ucTreeView1_NodeCheck(ByVal hNode As Long)
  825.     Debug.Print "ucTreeView1_NodeCheck - hNode = "; hNode
  826. End Sub
  827. Private Sub ucTreeView1_NodeDblClick(ByVal hNode As Long)
  828.     Debug.Print "ucTreeView1_NodeDblClick - hNode = "; hNode
  829. End Sub
  830. Private Sub ucTreeView1_Resize()
  831. '   Debug.Print "ucTreeView1_Resize"
  832. End Sub
  833. '==== Misc.
  834. Private Sub pvClearInfo()
  835.     lblhNodeVal.Caption = "0"
  836.     lblKeyVal.Caption = vbNullString
  837.     lblFullPathVal.Caption = vbNullString
  838.     chkBold.Value = 0
  839.     chkGhosted.Value = 0
  840.     chkHilited.Value = 0
  841.     txtText.Text = vbNullString
  842.     txthRelative.Text = lblhNodeVal.Caption
  843. End Sub
  844. Private Sub pvFlattenButton(ByVal hButton As Long)
  845.   Dim lS As Long
  846.     lS = GetWindowLong(hButton, GWL_STYLE)
  847.     Call SetWindowLong(hButton, GWL_STYLE, lS Or BS_FLAT)
  848. End Sub
  849.