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-ucTree1887935132005.psc / Test.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2004-11-03  |  22.8 KB  |  653 lines

  1. VERSION 5.00
  2. Begin VB.Form fTest 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "ucTreeView 1.3 - Test"
  5.    ClientHeight    =   6960
  6.    ClientLeft      =   45
  7.    ClientTop       =   615
  8.    ClientWidth     =   9450
  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     =   464
  22.    ScaleMode       =   3  'Pixel
  23.    ScaleWidth      =   630
  24.    StartUpPosition =   2  'CenterScreen
  25.    Begin Test.ucTreeView ucTreeView1 
  26.       Height          =   3960
  27.       Left            =   150
  28.       TabIndex        =   1
  29.       Top             =   540
  30.       Width           =   3405
  31.       _ExtentX        =   6006
  32.       _ExtentY        =   6985
  33.    End
  34.    Begin VB.PictureBox fraOLEDragInsertStyle 
  35.       BorderStyle     =   0  'None
  36.       Height          =   555
  37.       Left            =   5325
  38.       ScaleHeight     =   555
  39.       ScaleWidth      =   1875
  40.       TabIndex        =   11
  41.       TabStop         =   0   'False
  42.       Top             =   4620
  43.       Width           =   1875
  44.       Begin VB.OptionButton optOLEDragInsertStyle 
  45.          Appearance      =   0  'Flat
  46.          Caption         =   "DropHilite"
  47.          Height          =   225
  48.          Index           =   1
  49.          Left            =   0
  50.          TabIndex        =   13
  51.          Top             =   255
  52.          Value           =   -1  'True
  53.          Width           =   1470
  54.       End
  55.       Begin VB.OptionButton optOLEDragInsertStyle 
  56.          Appearance      =   0  'Flat
  57.          Caption         =   "InsertMark (default)"
  58.          Height          =   225
  59.          Index           =   0
  60.          Left            =   0
  61.          TabIndex        =   12
  62.          Top             =   0
  63.          Width           =   1830
  64.       End
  65.    End
  66.    Begin VB.PictureBox fraDropEffect 
  67.       BorderStyle     =   0  'None
  68.       Height          =   555
  69.       Left            =   1110
  70.       ScaleHeight     =   555
  71.       ScaleWidth      =   1530
  72.       TabIndex        =   7
  73.       TabStop         =   0   'False
  74.       Top             =   4620
  75.       Width           =   1530
  76.       Begin VB.OptionButton optDropEffect 
  77.          Appearance      =   0  'Flat
  78.          Caption         =   "Copy"
  79.          Height          =   225
  80.          Index           =   1
  81.          Left            =   0
  82.          TabIndex        =   9
  83.          Top             =   255
  84.          Value           =   -1  'True
  85.          Width           =   960
  86.       End
  87.       Begin VB.OptionButton optDropEffect 
  88.          Appearance      =   0  'Flat
  89.          Caption         =   "Move"
  90.          Height          =   225
  91.          Index           =   0
  92.          Left            =   0
  93.          TabIndex        =   8
  94.          Top             =   0
  95.          Width           =   960
  96.       End
  97.    End
  98.    Begin VB.ComboBox Combo1 
  99.       Height          =   315
  100.       Left            =   7365
  101.       OLEDragMode     =   1  'Automatic
  102.       TabIndex        =   5
  103.       Top             =   2565
  104.       Width           =   1935
  105.    End
  106.    Begin VB.ListBox List1 
  107.       Height          =   840
  108.       Left            =   7365
  109.       MultiSelect     =   2  'Extended
  110.       OLEDragMode     =   1  'Automatic
  111.       TabIndex        =   4
  112.       Top             =   1575
  113.       Width           =   1920
  114.    End
  115.    Begin VB.TextBox Text1 
  116.       Height          =   885
  117.       HideSelection   =   0   'False
  118.       Left            =   7365
  119.       MultiLine       =   -1  'True
  120.       OLEDragMode     =   1  'Automatic
  121.       TabIndex        =   3
  122.       Top             =   540
  123.       Width           =   1920
  124.    End
  125.    Begin Test.ucTreeView ucTreeView2 
  126.       Height          =   3960
  127.       Left            =   3750
  128.       TabIndex        =   2
  129.       Top             =   540
  130.       Width           =   3405
  131.       _ExtentX        =   6006
  132.       _ExtentY        =   6985
  133.    End
  134.    Begin VB.Label lblNodeFullPath 
  135.       Caption         =   "NodeFullPath:"
  136.       Height          =   240
  137.       Left            =   300
  138.       TabIndex        =   19
  139.       Top             =   6255
  140.       Width           =   990
  141.    End
  142.    Begin VB.Label lblNodeFullPathVal 
  143.       Height          =   585
  144.       Left            =   1365
  145.       TabIndex        =   20
  146.       Top             =   6255
  147.       Width           =   7920
  148.    End
  149.    Begin VB.Label lblInsertAfterVal 
  150.       Height          =   240
  151.       Left            =   1365
  152.       TabIndex        =   18
  153.       Top             =   5955
  154.       Width           =   1500
  155.    End
  156.    Begin VB.Label lblInsertAfter 
  157.       Caption         =   "InsertAfter:"
  158.       Height          =   240
  159.       Left            =   300
  160.       TabIndex        =   17
  161.       Top             =   5955
  162.       Width           =   990
  163.    End
  164.    Begin VB.Label lblNodeDrop 
  165.       Caption         =   "hNodeDrop:"
  166.       Height          =   240
  167.       Left            =   300
  168.       TabIndex        =   15
  169.       Top             =   5670
  170.       Width           =   990
  171.    End
  172.    Begin VB.Label lblDragDropTitle 
  173.       BackColor       =   &H80000010&
  174.       Caption         =   " OLE drag & drop test: Move/copy to second TreeView"
  175.       BeginProperty Font 
  176.          Name            =   "Tahoma"
  177.          Size            =   8.25
  178.          Charset         =   0
  179.          Weight          =   700
  180.          Underline       =   0   'False
  181.          Italic          =   0   'False
  182.          Strikethrough   =   0   'False
  183.       EndProperty
  184.       ForeColor       =   &H80000014&
  185.       Height          =   225
  186.       Left            =   150
  187.       TabIndex        =   0
  188.       Top             =   180
  189.       UseMnemonic     =   0   'False
  190.       Width           =   9135
  191.    End
  192.    Begin VB.Label lblNodeDropVal 
  193.       Height          =   240
  194.       Left            =   1365
  195.       TabIndex        =   16
  196.       Top             =   5670
  197.       Width           =   1500
  198.    End
  199.    Begin VB.Label lblOLEDropInfo 
  200.       BackColor       =   &H80000010&
  201.       Caption         =   " OLE drop info:"
  202.       BeginProperty Font 
  203.          Name            =   "Tahoma"
  204.          Size            =   8.25
  205.          Charset         =   0
  206.          Weight          =   700
  207.          Underline       =   0   'False
  208.          Italic          =   0   'False
  209.          Strikethrough   =   0   'False
  210.       EndProperty
  211.       ForeColor       =   &H80000014&
  212.       Height          =   225
  213.       Left            =   150
  214.       TabIndex        =   14
  215.       Top             =   5310
  216.       UseMnemonic     =   0   'False
  217.       Width           =   9135
  218.    End
  219.    Begin VB.Label lblOLEDragInsertStyle 
  220.       Caption         =   "OLEDragInsertStyle:"
  221.       Height          =   270
  222.       Left            =   3765
  223.       TabIndex        =   10
  224.       Top             =   4620
  225.       Width           =   1515
  226.    End
  227.    Begin VB.Label lblDropEffect 
  228.       Caption         =   "Drop effect:"
  229.       Height          =   270
  230.       Left            =   165
  231.       TabIndex        =   6
  232.       Top             =   4620
  233.       Width           =   1005
  234.    End
  235.    Begin VB.Menu mnuFileTop 
  236.       Caption         =   "&File"
  237.       Begin VB.Menu mnuFile 
  238.          Caption         =   "E&xit"
  239.          Index           =   0
  240.          Shortcut        =   ^X
  241.       End
  242.    End
  243.    Begin VB.Menu mnuTestTop 
  244.       Caption         =   "&Test"
  245.       Begin VB.Menu mnuTest 
  246.          Caption         =   "&Reset all"
  247.          Index           =   0
  248.          Shortcut        =   ^R
  249.       End
  250.    End
  251.    Begin VB.Menu mnuPSCTop 
  252.       Caption         =   "&PSC"
  253.       Begin VB.Menu mnuPSC 
  254.          Caption         =   "Go to ucTreeView 1.3 PSC page..."
  255.          Index           =   0
  256.       End
  257.       Begin VB.Menu mnuPSC 
  258.          Caption         =   "Go to ucTreeView 1.2 PSC page..."
  259.          Index           =   1
  260.       End
  261.    End
  262.    Begin VB.Menu mnuContextTop 
  263.       Caption         =   "Context"
  264.       Visible         =   0   'False
  265.       Begin VB.Menu mnuContext 
  266.          Caption         =   "Delete"
  267.          Index           =   0
  268.       End
  269.       Begin VB.Menu mnuContext 
  270.          Caption         =   "-"
  271.          Index           =   1
  272.       End
  273.       Begin VB.Menu mnuContext 
  274.          Caption         =   "Expand children"
  275.          Index           =   2
  276.       End
  277.       Begin VB.Menu mnuContext 
  278.          Caption         =   "Collapse children"
  279.          Index           =   3
  280.       End
  281.       Begin VB.Menu mnuContext 
  282.          Caption         =   "-"
  283.          Index           =   4
  284.       End
  285.       Begin VB.Menu mnuContext 
  286.          Caption         =   "Cancel"
  287.          Index           =   5
  288.       End
  289.    End
  290. Attribute VB_Name = "fTest"
  291. Attribute VB_GlobalNameSpace = False
  292. Attribute VB_Creatable = False
  293. Attribute VB_PredeclaredId = True
  294. Attribute VB_Exposed = False
  295. Option Explicit
  296. '-- Some API
  297. Private Const GWL_STYLE As Long = (-16)
  298. Private Const BS_FLAT   As Long = &H8000&
  299. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
  300. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  301. Private Const SW_SHOW   As Long = 5
  302. Private Declare Function ShellExecute Lib "shell32" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  303. Private Const URL_UCTREEVIEW_1_3 As String = "http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=57047&lngWId=1"
  304. Private Const URL_UCTREEVIEW_1_2 As String = "http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=56958&lngWId=1"
  305. '========================================================================================
  306. ' Initialize all...
  307. '========================================================================================
  308. Private m_lKey As Long ' Auto-increased key for ucTreeView2
  309. Private Sub Form_Load()
  310.   Dim oCtl As Control
  311.     Call pvInitializeTreeView1
  312.     Call pvInitializeTreeView2
  313.     Call pvFillTreeView1
  314.     Call pvFillTreeView2
  315.     Call pvFillStandartControls
  316.     For Each oCtl In fTest.Controls
  317.         If (TypeOf oCtl Is CommandButton) Then
  318.             Call pvFlattenButton(oCtl.hWnd)
  319.         End If
  320.     Next oCtl
  321. End Sub
  322. Private Sub pvInitializeTreeView1()
  323.   Dim lResIcon As Long
  324.     With ucTreeView1
  325.         
  326.         Call .Initialize
  327.         Call .InitializeImageList
  328.         
  329.         For lResIcon = 101 To 105
  330.             Call .AddIcon(VB.LoadResPicture(lResIcon, vbResIcon))
  331.         Next lResIcon
  332.         
  333.         .ItemHeight = 18
  334.         .HasButtons = True
  335.         .HasLines = True
  336.         .HasRootLines = True
  337.         .OLEDragMode = [drgAutomatic]
  338.         .OLEDropMode = [drpNone] 'Default
  339.     End With
  340. End Sub
  341. Private Sub pvInitializeTreeView2()
  342.   Dim lResIcon As Long
  343.     With ucTreeView2
  344.         
  345.         Call .Initialize
  346.         Call .InitializeImageList
  347.         
  348.         For lResIcon = 101 To 108
  349.             Call .AddIcon(LoadResPicture(lResIcon, vbResIcon))
  350.         Next lResIcon
  351.         
  352.         .ItemHeight = 18
  353.         .HasButtons = True
  354.         .HasLines = True
  355.         .HasRootLines = True
  356.         .CheckBoxes = True
  357.         .LabelEdit = True
  358.         
  359.         .BackColor = &HC8FFC8
  360.         .ForeColor = &H0
  361.         .LineColor = &H8000&
  362.         
  363.         .OLEDragMode = [drgNone] 'Default
  364.         .OLEDropMode = [drpManual]
  365.         
  366.         .OLEDragInsertStyle = [disDropHilite]
  367.         .OLEDragAutoExpand = True
  368.     End With
  369. End Sub
  370. Private Sub pvFillTreeView1()
  371.   Dim lKey        As Long
  372.   Dim lBook       As Long
  373.   Dim lChapter    As Long
  374.   Dim lPage       As Long
  375.   Dim lNote       As Long
  376.   Dim hBook       As Long
  377.   Dim hChapter    As Long
  378.   Dim hPage       As Long
  379.     With ucTreeView1
  380.         
  381.         Call .SetRedrawMode(Enable:=False)
  382.         Call .Clear
  383.         
  384.         For lBook = 1 To 1
  385.             lKey = lKey + 1
  386.             hBook = .AddNode(, , lKey, "Book #" & lBook, 0, 1)
  387.             
  388.             For lChapter = 1 To 5
  389.                 lKey = lKey + 1
  390.                 hChapter = .AddNode(hBook, , lKey, "Chapter #" & lChapter, 0, 1)
  391.                 
  392.                 For lPage = 1 To 10
  393.                     lKey = lKey + 1
  394.                     hPage = .AddNode(hChapter, , lKey, "Page #" & lPage, 2, 2)
  395.                     
  396.                     For lNote = 1 To 2
  397.                         lKey = lKey + 1
  398.                         Call .AddNode(hPage, , lKey, "Note #" & lNote, 3, 3)
  399.         
  400.         Next lNote, lPage, lChapter, lBook
  401.         
  402.         .SelectedNode = .NodeRoot
  403.         Call .Expand(.SelectedNode)
  404.         Call .SetRedrawMode(Enable:=True)
  405.     End With
  406. End Sub
  407. Private Sub pvFillTreeView2()
  408.   Dim lFolder    As Long
  409.   Dim lSubFolder As Long
  410.   Dim hFolder    As Long
  411.     With ucTreeView2
  412.         
  413.         Call .SetRedrawMode(Enable:=False)
  414.         Call .Clear
  415.         
  416.         For lFolder = 1 To 2
  417.             m_lKey = m_lKey + 1
  418.             hFolder = .AddNode(, , m_lKey, "Folder #" & lFolder, 5, 6)
  419.             
  420.             For lSubFolder = 1 To 10
  421.                 m_lKey = m_lKey + 1
  422.                 
  423.                 Call .AddNode(hFolder, , m_lKey, "Folder #" & lFolder & "." & lSubFolder, 5, 6)
  424.         
  425.         Next lSubFolder, lFolder
  426.         
  427.         .SelectedNode = .NodeRoot
  428.         Call .Expand(0, ExpandChildren:=True)
  429.         Call .EnsureVisible(.SelectedNode)
  430.         Call .SetRedrawMode(Enable:=True)
  431.     End With
  432. End Sub
  433. Private Sub pvFillStandartControls()
  434.     Text1.Text = "TextBox text"
  435.     Call List1.Clear
  436.     Call List1.AddItem("ListBox item 0")
  437.     Call List1.AddItem("ListBox item 1")
  438.     Call List1.AddItem("ListBox item 2")
  439.     Call Combo1.Clear
  440.     Call Combo1.AddItem("ComboBox item 0")
  441.     Call Combo1.AddItem("ComboBox item 1")
  442.     Call Combo1.AddItem("ComboBox item 2")
  443.     Combo1.Text = Combo1.List(0)
  444. End Sub
  445. '========================================================================================
  446. ' Menus
  447. '========================================================================================
  448. Private Sub mnuFile_Click(Index As Integer)
  449.     Call Unload(Me)
  450. End Sub
  451. Private Sub mnuTest_Click(Index As Integer)
  452.     Call pvFillTreeView1
  453.     Call pvFillTreeView2
  454.     Call pvFillStandartControls
  455. End Sub
  456. Private Sub mnuPSC_Click(Index As Integer)
  457.     Select Case Index
  458.         Case 0
  459.             Call pvNavigate(URL_UCTREEVIEW_1_3)
  460.         Case 1
  461.             Call pvNavigate(URL_UCTREEVIEW_1_2)
  462.     End Select
  463. End Sub
  464. Private Sub mnuContext_Click(Index As Integer)
  465.     With ucTreeView2
  466.         Select Case Index
  467.             Case 0
  468.                 Call .DeleteNode(.SelectedNode)
  469.             Case 2
  470.                 Call .Expand(.SelectedNode, True)
  471.             Case 3
  472.                 Call .Collapse(.SelectedNode, True)
  473.         End Select
  474.     End With
  475. End Sub
  476. Private Sub ucTreeView2_MouseDown(Button As Integer, Shift As Integer, x As Long, y As Long)
  477.   Dim hNode As Long
  478.     With ucTreeView2
  479.         If (Button = vbRightButton) Then
  480.             hNode = .HitTest(x, y, False)
  481.             If (hNode) Then
  482.                 .SelectedNode = hNode
  483.                 Call Me.PopupMenu(mnuContextTop, , .Left + x, .Top + y, mnuContext(0))
  484.             End If
  485.         End If
  486.     End With
  487. End Sub
  488. Private Sub ucTreeView2_NodeCheck(ByVal hNode As Long)
  489.     With ucTreeView2
  490.         Call .CheckChildren(hNode, .NodeChecked(hNode))
  491.     End With
  492. End Sub
  493. '========================================================================================
  494. ' OLE Drag & Drop test
  495. '========================================================================================
  496. Private Sub optOLEDragInsertStyle_Click(Index As Integer)
  497.     ucTreeView2.OLEDragInsertStyle = Index
  498. End Sub
  499. Private Sub ucTreeView1_OLEStartDrag(Data As DataObject, AllowedEffects As Long)
  500.     '-- ucTreeView1 has started dragging. Set allowed effects:
  501.     AllowedEffects = IIf(optDropEffect(0), vbDropEffectMove, vbDropEffectCopy)
  502. End Sub
  503. Private Sub ucTreeView2_OLEDragOver(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single, State As Integer)
  504.         
  505.   Dim hNodeDrop   As Long
  506.   Dim InsertAfter As Boolean
  507.     '-- 'Something is over' ucTreeView2:
  508.     If (Effect <> vbOLEDropNone) Then
  509.         
  510.         '-- Get Drop info:
  511.         Call ucTreeView2.OLEGetDropInfo(hNodeDrop, InsertAfter)
  512.         
  513.         lblNodeDropVal.Caption = hNodeDrop
  514.         lblInsertAfterVal.Caption = IIf(InsertAfter, "True", "False")
  515.         lblNodeFullPathVal.Caption = ucTreeView2.NodeFullPath(hNodeDrop)
  516.         
  517.       Else
  518.         lblNodeDropVal.Caption = vbNullString
  519.         lblInsertAfterVal.Caption = vbNullString
  520.         lblNodeFullPathVal.Caption = vbNullString
  521.     End If
  522. End Sub
  523. Private Sub ucTreeView2_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
  524.   Dim hNodeDrag     As Long
  525.   Dim hNodeDrop     As Long
  526.   Dim hNodeInsert   As Long
  527.   Dim hWndTreeView  As Long
  528.   Dim bInstertAfter As Boolean
  529.   Dim eRelation     As tvRelationConstants
  530.   Dim sText()       As String
  531.   Dim lIdx          As Long
  532.     '-- Something has been Dropped on ucTreevView2....
  533.     With ucTreeView2
  534.         
  535.         '-- Is there our format (ucTreeView)
  536.         If (.OLEIsMyFormat(Data)) Then
  537.             
  538.             '-- Yes, extract Drag info (TreeView handle and node-drag)
  539.             Call .OLEGetDragInfo(Data, hWndTreeView, hNodeDrag)
  540.             
  541.             '-- Extract Drop info (node-over and insert-after flag)
  542.             '   Insert-after flag will be always True when OLEDragInsertStyle=[disDropHilite]
  543.             '   It's your choice decide how to insert data...
  544.             Call .OLEGetDropInfo(hNodeDrop, bInstertAfter)
  545.             
  546.             '-- Check insertion relation
  547.             If (.OLEDragInsertStyle = [disInsertMark]) Then
  548.                 If (bInstertAfter = False) Then
  549.                     eRelation = [rPrevious]
  550.                   Else
  551.                     eRelation = [rNext]
  552.                 End If
  553.               Else
  554.                 eRelation = [rLast]
  555.             End If
  556.             '-- Let's insert our node/s
  557.             Call pvCopyNode(hNodeDrag, hNodeDrop, eRelation)
  558.             
  559.             '-- Are we moving nodes ?
  560.             If (optDropEffect(0)) Then
  561.                 Call ucTreeView1.DeleteNode(hNodeDrag)
  562.             End If
  563.           
  564.         '-- Not there, check format
  565.         Else
  566.             
  567.             Select Case True
  568.                 
  569.                 '-- Text format ?
  570.                 Case Data.GetFormat(vbCFText)
  571.                     
  572.                     '-- We can have multiple items (multi-select listbox)
  573.                     sText() = Split(Data.GetData(vbCFText), vbCrLf)
  574.                     
  575.                     '-- Extract Drop info (node-over and insert-after flag)
  576.                     Call .OLEGetDropInfo(hNodeDrop, bInstertAfter)
  577.                     
  578.                     '-- Let's insert our first string
  579.                     If (.OLEDragInsertStyle = [disInsertMark]) Then
  580.                         m_lKey = m_lKey + 1
  581.                         hNodeInsert = .AddNode(hNodeDrop, IIf(bInstertAfter, [rNext], [rPrevious]), m_lKey, sText(0), 7, 7)
  582.                       Else
  583.                         m_lKey = m_lKey + 1
  584.                         hNodeInsert = .AddNode(hNodeDrop, [rFirst], m_lKey, sText(0), 7, 7)
  585.                     End If
  586.                     '-- More strings ? (insert as [rNext] of previous inserted
  587.                     For lIdx = 1 To UBound(sText())
  588.                         m_lKey = m_lKey + 1
  589.                         hNodeInsert = .AddNode(hNodeInsert, [rNext], m_lKey, sText(lIdx), 7, 7)
  590.                     Next lIdx
  591.                     
  592.                     '-- Ensure visible last inserted
  593.                     Call .EnsureVisible(hNodeInsert)
  594.                 '-- No more formats checked here
  595.                 '   This should be checked on OLEDragOver() event.
  596.                 '   There, you can change your cursor, cancel, etc.
  597.                 Case Else
  598.                     
  599.                     Call MsgBox("Data format not supported, sorry.", vbInformation)
  600.             End Select
  601.         End If
  602.     End With
  603.     lblNodeDropVal.Caption = vbNullString
  604.     lblInsertAfterVal.Caption = vbNullString
  605.     lblNodeFullPathVal.Caption = vbNullString
  606. End Sub
  607. Private Sub pvCopyNode(ByVal hNodeFrom As Long, ByVal hNodeTo As Long, ByVal eRelation As tvRelationConstants)
  608. ' Important!
  609. '   This sub. as well as next one, are using ucTreeView2 object to manage hNodes.
  610. '   In fact, it doesn't matter which object we are using: hNodes are handles and our controls are
  611. '   working as wrappers. But be careful: this only is true for hNode navigation! Forget to delete
  612. '   nodes or perform any other operation that involves background operations with current ucTreeView
  613. '   internal collection/array, as well as change any property related to appearance, style, etc.
  614.     With ucTreeView2
  615.         
  616.         m_lKey = m_lKey + 1
  617.         hNodeTo = .AddNode(hNodeTo, eRelation, m_lKey, .NodeText(hNodeFrom), .NodeImage(hNodeFrom), .NodeSelectedImage(hNodeFrom))
  618.         
  619.         Call .EnsureVisible(hNodeTo)
  620.         Call pvCopyChildren(hNodeFrom, hNodeTo)
  621.     End With
  622. End Sub
  623. Private Sub pvCopyChildren(ByVal hNodeFrom As Long, ByVal hNodeTo As Long)
  624.   Dim hNextFrom  As Long
  625.   Dim hNextTo    As Long
  626.         
  627.     With ucTreeView2
  628.         hNextFrom = .NodeChild(hNodeFrom)
  629.         hNextTo = hNodeTo
  630.         
  631.         Do While hNextFrom
  632.             
  633.             m_lKey = m_lKey + 1
  634.             hNodeTo = .AddNode(hNextTo, , m_lKey, .NodeText(hNextFrom), .NodeImage(hNextFrom), .NodeSelectedImage(hNextFrom))
  635.         
  636.             Call pvCopyChildren(hNextFrom, hNodeTo)
  637.             hNextFrom = .NodeNextSibling(hNextFrom)
  638.         Loop
  639.     End With
  640. End Sub
  641. '========================================================================================
  642. ' Forget this...
  643. '========================================================================================
  644. Private Sub pvFlattenButton(ByVal hButton As Long)
  645.   Dim lS As Long
  646.     lS = GetWindowLong(hButton, GWL_STYLE)
  647.     Call SetWindowLong(hButton, GWL_STYLE, lS Or BS_FLAT)
  648. End Sub
  649. Private Sub pvNavigate(ByVal sURL As String)
  650.     '-- Open URL
  651.     Call ShellExecute(Me.hWnd, "open", sURL, vbNullString, vbNullString, SW_SHOW)
  652. End Sub
  653.