home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / activex / demos / oletrial / samples / vb / mhtree / fmhtree.frm (.txt) next >
Encoding:
Visual Basic Form  |  1995-11-28  |  35.5 KB  |  947 lines

  1. VERSION 4.00
  2. Begin VB.Form fMhTree 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Form1"
  5.    ClientHeight    =   6276
  6.    ClientLeft      =   1116
  7.    ClientTop       =   1836
  8.    ClientWidth     =   6840
  9.    BeginProperty Font 
  10.       name            =   "MS Sans Serif"
  11.       charset         =   0
  12.       weight          =   700
  13.       size            =   7.8
  14.       underline       =   0   'False
  15.       italic          =   0   'False
  16.       strikethrough   =   0   'False
  17.    EndProperty
  18.    ForeColor       =   &H80000008&
  19.    Height          =   6876
  20.    Left            =   1068
  21.    LinkTopic       =   "Form1"
  22.    ScaleHeight     =   6276
  23.    ScaleWidth      =   6840
  24.    Top             =   1284
  25.    Width           =   6936
  26.    Begin VB.ListBox lstSelect 
  27.       Height          =   1968
  28.       Left            =   3480
  29.       TabIndex        =   4
  30.       Top             =   480
  31.       Width           =   3252
  32.    End
  33.    Begin VB.CommandButton cmdAddSelect 
  34.       Caption         =   "Command1"
  35.       Height          =   495
  36.       Left            =   120
  37.       TabIndex        =   3
  38.       Top             =   5640
  39.       Width           =   3135
  40.    End
  41.    Begin Mh3dlblLib.Mh3dLabel lblTree 
  42.       Height          =   5412
  43.       Left            =   108
  44.       TabIndex        =   6
  45.       Top             =   108
  46.       Width           =   3132
  47.       _Version        =   65536
  48.       _ExtentX        =   5525
  49.       _ExtentY        =   9546
  50.       _StockProps     =   77
  51.       TintColor       =   16711935
  52.       Caption         =   ""
  53.       Alignment       =   0
  54.       BevelSize       =   1
  55.       BorderStyle     =   0
  56.       Picture         =   "fMhTree.frx":0000
  57.       Begin Mhtr200Lib.MhTree MhTree1 
  58.          Height          =   5124
  59.          Left            =   108
  60.          TabIndex        =   7
  61.          Top             =   144
  62.          Width           =   2868
  63.          _Version        =   65536
  64.          _ExtentX        =   5059
  65.          _ExtentY        =   9038
  66.          _StockProps     =   79
  67.          BackColor       =   -2147483643
  68.          TintColor       =   16711935
  69.          ListCount       =   1000
  70.          ScreenUpdate    =   -1  'True
  71.          Columns         =   32
  72.          Pictures        =   15
  73.          IconHeight      =   16
  74.          IconWidth       =   16
  75.          DefaultPics     =   0   'False
  76.          Groups          =   2
  77.          Group           =   0
  78.          TitleHeight     =   0
  79.          TitleBold       =   0   'False
  80.          SingleSelect    =   -1  'True
  81.          ExtendedSelect  =   0   'False
  82.          MDI             =   0   'False
  83.          MaxButton       =   0   'False
  84.          MinButton       =   0   'False
  85.          ControlBox      =   0   'False
  86.          WindowState     =   0
  87.          Sizeable        =   0   'False
  88.          Icon            =   "fMhTree.frx":001C
  89.          Fonts           =   0
  90.          Column          =   0
  91.          FillColor       =   16777215
  92.          LineColor       =   0
  93.          LineWidth       =   1
  94.          Path            =   "."
  95.          Normal          =   -1  'True
  96.          Hidden          =   -1  'True
  97.          Archive         =   -1  'True
  98.          ReadOnly        =   -1  'True
  99.          System          =   -1  'True
  100.          Dir             =   -1  'True
  101.          ScaleMode       =   3
  102.          FontStyle       =   0
  103.          BevelSizeInner  =   0
  104.          BevelStyleInner =   0
  105.          LightColor      =   16777215
  106.          ShadowColor     =   8421504
  107.          BorderColor     =   0
  108.          TextColor       =   0
  109.          HighColor       =   16777215
  110.          SelectedColor   =   8388608
  111.          DividerStyle    =   0
  112.          BitmapTransparent=   0   'False
  113.          Connect         =   -1  'True
  114.          TextExtent      =   0
  115.          TransparentColor=   255
  116.          NoFocusRect     =   0   'False
  117.          FireDrawItem    =   0   'False
  118.          DrawItemLeft    =   0
  119.          ColTitle        =   ""
  120.          ColTitle        =   ""
  121.          ColTitle        =   ""
  122.          ColTitle        =   ""
  123.          ColTitle        =   ""
  124.          ColTitle        =   ""
  125.          ColTitle        =   ""
  126.          ColTitle        =   ""
  127.          ColTitle        =   ""
  128.          ColTitle        =   ""
  129.          ColTitle        =   ""
  130.          ColTitle        =   ""
  131.          ColTitle        =   ""
  132.          ColTitle        =   ""
  133.          ColTitle        =   ""
  134.          ColTitle        =   ""
  135.          ColTitle        =   ""
  136.          ColTitle        =   ""
  137.          ColTitle        =   ""
  138.          ColTitle        =   ""
  139.          ColTitle        =   ""
  140.          ColTitle        =   ""
  141.          ColTitle        =   ""
  142.          ColTitle        =   ""
  143.          ColTitle        =   ""
  144.          ColTitle        =   ""
  145.          ColTitle        =   ""
  146.          ColTitle        =   ""
  147.          ColTitle        =   ""
  148.          ColTitle        =   ""
  149.          ColTitle        =   ""
  150.          ColTitle        =   ""
  151.       End
  152.    End
  153.    Begin MhcommdlLib.MhCommonDialog MhCommonDialog1 
  154.       Height          =   336
  155.       Left            =   0
  156.       TabIndex        =   5
  157.       Top             =   0
  158.       Width           =   336
  159.       _Version        =   65536
  160.       _ExtentX        =   593
  161.       _ExtentY        =   593
  162.       _StockProps     =   4
  163.       TintColor       =   16711935
  164.       Filename        =   ""
  165.       DialogTop       =   0
  166.       DialogLeft      =   0
  167.       DialogWidth     =   0
  168.       DialogHeight    =   0
  169.       InitDir         =   ""
  170.       Filter          =   ""
  171.       DefaultExt      =   ""
  172.       DialogTitle     =   ""
  173.       FilterIndex     =   0
  174.       Flags           =   0
  175.       CancelError     =   0   'False
  176.       MaxFileSize     =   256
  177.       Color           =   0
  178.       Max             =   0
  179.       Min             =   0
  180.       Copies          =   0
  181.       FromPage        =   0
  182.       PrinterDefault  =   -1  'True
  183.       ToPage          =   0
  184.       HelpCommand     =   0
  185.       HelpContext     =   0
  186.       HelpFile        =   ""
  187.       HelpKey         =   ""
  188.    End
  189.    Begin VB.Label lblMoreXplain 
  190.       Appearance      =   0  'Flat
  191.       BackColor       =   &H80000005&
  192.       Caption         =   "Label1"
  193.       ForeColor       =   &H80000008&
  194.       Height          =   1452
  195.       Left            =   3480
  196.       TabIndex        =   2
  197.       Top             =   4680
  198.       Width           =   3252
  199.    End
  200.    Begin VB.Label lblXplain 
  201.       Appearance      =   0  'Flat
  202.       BackColor       =   &H80000005&
  203.       Caption         =   "Label1"
  204.       ForeColor       =   &H80000008&
  205.       Height          =   1812
  206.       Left            =   3480
  207.       TabIndex        =   1
  208.       Top             =   2760
  209.       Width           =   3252
  210.    End
  211.    Begin VB.Label lblSelect 
  212.       Appearance      =   0  'Flat
  213.       BackColor       =   &H80000005&
  214.       Caption         =   "Label1"
  215.       ForeColor       =   &H80000008&
  216.       Height          =   252
  217.       Left            =   3480
  218.       TabIndex        =   0
  219.       Top             =   120
  220.       Width           =   3252
  221.    End
  222.    Begin VB.Menu mnuFile 
  223.       Caption         =   "&File"
  224.       Begin VB.Menu itmExit 
  225.          Caption         =   "E&xit"
  226.       End
  227.    End
  228.    Begin VB.Menu itmFillTree 
  229.       Caption         =   "Fill &Tree"
  230.       Begin VB.Menu itmAddItem 
  231.          Caption         =   "Add&Item Method"
  232.       End
  233.       Begin VB.Menu itmDirectory 
  234.          Caption         =   "&Directory"
  235.       End
  236.       Begin VB.Menu itmList 
  237.          Caption         =   "&List Method"
  238.       End
  239.       Begin VB.Menu itmPictures 
  240.          Caption         =   "&Pictures"
  241.       End
  242.    End
  243.    Begin VB.Menu mnuOptions 
  244.       Caption         =   "&Options"
  245.       Begin VB.Menu itmBevelSize 
  246.          Caption         =   "B&evel Size"
  247.          Begin VB.Menu itmBevel 
  248.             Caption         =   "&None"
  249.             Checked         =   -1  'True
  250.             Index           =   0
  251.          End
  252.          Begin VB.Menu itmBevel 
  253.             Caption         =   "&Small"
  254.             Index           =   1
  255.          End
  256.          Begin VB.Menu itmBevel 
  257.             Caption         =   "Lar&ge"
  258.             Index           =   2
  259.          End
  260.       End
  261.       Begin VB.Menu itmBevelStyle 
  262.          Caption         =   "Be&vel Style"
  263.          Begin VB.Menu itmStyle 
  264.             Caption         =   "Lo&wered"
  265.             Index           =   0
  266.          End
  267.          Begin VB.Menu itmStyle 
  268.             Caption         =   "&Raised"
  269.             Index           =   1
  270.          End
  271.       End
  272.       Begin VB.Menu itmMultiSelect 
  273.          Caption         =   "Extended Selection"
  274.       End
  275.       Begin VB.Menu itmSizeable 
  276.          Caption         =   "Si&zeable"
  277.       End
  278.    End
  279.    Begin VB.Menu mnuColors 
  280.       Caption         =   "&Colors"
  281.       Begin VB.Menu itmGlobal 
  282.          Caption         =   "Global Colors"
  283.          Begin VB.Menu itmGlobalColor 
  284.             Caption         =   "Border Color"
  285.             Index           =   0
  286.          End
  287.          Begin VB.Menu itmGlobalColor 
  288.             Caption         =   "Fill Color"
  289.             Index           =   1
  290.          End
  291.          Begin VB.Menu itmGlobalColor 
  292.             Caption         =   "High Color"
  293.             Index           =   2
  294.          End
  295.          Begin VB.Menu itmGlobalColor 
  296.             Caption         =   "Light Color"
  297.             Index           =   3
  298.          End
  299.          Begin VB.Menu itmGlobalColor 
  300.             Caption         =   "Line Color"
  301.             Index           =   4
  302.          End
  303.          Begin VB.Menu itmGlobalColor 
  304.             Caption         =   "Selected Color"
  305.             Index           =   5
  306.          End
  307.          Begin VB.Menu itmGlobalColor 
  308.             Caption         =   "Shadow Color"
  309.             Index           =   6
  310.          End
  311.          Begin VB.Menu itmGlobalColor 
  312.             Caption         =   "Text Color"
  313.             Index           =   7
  314.          End
  315.       End
  316.       Begin VB.Menu itmColumnColors 
  317.          Caption         =   "Change Colors of Column 1"
  318.          Begin VB.Menu itmColColor 
  319.             Caption         =   "Column Back Color"
  320.             Index           =   0
  321.          End
  322.          Begin VB.Menu itmColColor 
  323.             Caption         =   "Column Fore Color"
  324.             Index           =   1
  325.          End
  326.          Begin VB.Menu itmColColor 
  327.             Caption         =   "Column High Color"
  328.             Index           =   2
  329.          End
  330.       End
  331.       Begin VB.Menu itmGroupsColors 
  332.          Caption         =   "Change Colors of Group 1"
  333.          Begin VB.Menu itmGroupColor 
  334.             Caption         =   "Group Back Color"
  335.             Index           =   0
  336.          End
  337.          Begin VB.Menu itmGroupColor 
  338.             Caption         =   "Group Fore Color"
  339.             Index           =   1
  340.          End
  341.          Begin VB.Menu itmGroupColor 
  342.             Caption         =   "Group High Color"
  343.             Index           =   2
  344.          End
  345.       End
  346.       Begin VB.Menu itmListsColors 
  347.          Caption         =   "Change Colors of Selected Item"
  348.          Begin VB.Menu itmListColor 
  349.             Caption         =   "List Back Color"
  350.             Index           =   0
  351.          End
  352.          Begin VB.Menu itmListColor 
  353.             Caption         =   "List Fore Color"
  354.             Index           =   1
  355.          End
  356.          Begin VB.Menu itmListColor 
  357.             Caption         =   "List High Color"
  358.             Index           =   2
  359.          End
  360.       End
  361.    End
  362. Attribute VB_Name = "fMhTree"
  363. Attribute VB_Creatable = False
  364. Attribute VB_Exposed = False
  365. Option Explicit
  366. Const im_BORDERCOLOR = 0, im_FILLCOLOR = 1, im_HIGHCOLOR = 2, im_LIGHTCOLOR = 3, im_LINECOLOR = 4, im_SELECTEDCOLOR = 5, im_SHADOWCOLOR = 6, im_TEXTCOLOR = 7
  367. Const im_COLBACKCOLOR = 0, im_COLFORECOLOR = 1, im_COLHIGHCOLOR = 2
  368. Const im_GROUPBACKCOLOR = 0, im_GROUPFORECOLOR = 1, im_GROUPHIGHCOLOR = 2
  369. Const im_LISTBACKCOLOR = 0, im_LISTFORECOLOR = 1, im_LISTHIGHCOLOR = 2
  370. Const CC_PREVENTFULLOPEN = &H4&
  371. Const CDERR_DIALOGFAILURE = -32768
  372. Const im_TRUE = -1, im_FALSE = 0
  373. Const im_NONE = 0, im_SMALL = 1, im_LARGE = 2
  374. Const im_LOWERED = 0, im_RAISED = 1
  375. Const im_WHITE = &HFFFFFF
  376. Dim imDown As Integer
  377. Private Sub cmdAddSelect_Click()
  378. 'Add selected item to group 1
  379.     'Test to see if anything's selected. If nothing's selected, quit
  380.     If MhTree1.ListIndex = -1 Then
  381.         MsgBox "You must select something to add to the group.", 16, "MicroHelp"
  382.         Exit Sub
  383.     End If
  384.     MhTree1.ListGroup(MhTree1.ListIndex) = 1
  385.     lstSelect.AddItem "ListIndex " & Str$(MhTree1.ListIndex)
  386.     MhTree1.SetFocus
  387. End Sub
  388. Private Sub Form_Activate()
  389. 'Puts something in the tree
  390.     'This property needs to be set in the from_activate event
  391.     'If set in the form_load event, the tree won't populate.
  392.     MhTree1.SingleSelect = True
  393.     'Calls the routine to expand the tree
  394.     itmList_Click
  395.     'This tells tells the tree to expand all the columns
  396.     'Substituting any legitimate column number for -1 would
  397.     'tell the tree to expand to the column specified
  398.     MhTree1.Expand = MhTree1.Columns - 1
  399.     MhTree1.SetFocus
  400. End Sub
  401. Private Sub Form_Load()
  402. 'Because this is an example, all of the properties
  403. 'that are not specifically designtime properties suc
  404. 'as the name are set through code.
  405.     'Set defaults for the form
  406.     fMhTree.Caption = "MicroHelp MhTree Example"
  407.     'Set properties for the tree
  408.     MhTree1.Left = 20
  409.     MhTree1.Top = 30
  410.     MhTree1.Width = 3090
  411.     MhTree1.Height = 5350
  412.     'Set properties of command button
  413.     cmdAddSelect.Caption = "&Add Selected Item To Group One"
  414.     'Set properties for  labels
  415.     lblSelect.Caption = "Items in Group One"
  416.     lblTree.BevelSize = 2
  417.     lblXplain.Caption = "One of the most powerful aspects of the tree is the control's capacity to add items to different groups and set properties to affect only that group. For an illustration, select an item from the tree, click " & Chr$(34) & "Add To Group One" & Chr$(34) & " and then set the Group One color properties to see how you can address the group as a whole."
  418.     lblMoreXplain.Caption = "Note that the tree can be navigated by double-clicking with the mouse or by pressing the Spacebar when the selected item is a folder. Use the arrow keys to navigate up or down. It's great for building File Manager or Windows Explorer-style applications."
  419.  End Sub
  420. Private Sub itmAddItem_Click()
  421. 'This uses the .AddItem method to load some items in the MhTree1
  422. 'AddItem is a good choice for dynamically loading the box because
  423. 'each item will be displayed as it is loaded.
  424.     'This is a property that emulates the Clear method. We use it here
  425.     'so that we can put items in the tree.
  426.     MhTree1.ClearBox = 0
  427.     'Sets the list count and makes sure the filelist is not loaded.
  428.     MhTree1.FileList = False
  429.     MhTree1.DefaultPics = True
  430.     MhTree1.ListCount = 50
  431.     'For every branch off the trunk of the tree, a column must be declared
  432.     'Then set the address to the particular column whose properties you want
  433.     'to change.
  434.     MhTree1.Columns = 4
  435.     MhTree1.Column = 0
  436.     MhTree1.ColWidth = 10
  437.     MhTree1.ColPicture = MhTree1.Loadedpicture(1)
  438.     MhTree1.ColPictureSel = MhTree1.Loadedpicture(3)
  439.     MhTree1.Column = 1
  440.     MhTree1.ColWidth = 10
  441.     MhTree1.ColPicture = MhTree1.Loadedpicture(1)
  442.     MhTree1.ColPictureSel = MhTree1.Loadedpicture(3)
  443.     MhTree1.Column = 2
  444.     MhTree1.ColWidth = 10
  445.     MhTree1.ColPicture = MhTree1.Loadedpicture(5)
  446.     MhTree1.ColPictureSel = MhTree1.Loadedpicture(7)
  447.     MhTree1.Column = 3
  448.     MhTree1.ColWidth = 10
  449.     MhTree1.ColPicture = MhTree1.Loadedpicture(5)
  450.     MhTree1.ColPictureSel = MhTree1.Loadedpicture(7)
  451.     MhTree1.Column = 4
  452.     MhTree1.ColWidth = 10
  453.     MhTree1.ColPicture = MhTree1.Loadedpicture(5)
  454.     MhTree1.ColPictureSel = MhTree1.Loadedpicture(7)
  455.     'The tree always has a dummy item in it so we remove it.
  456.     MhTree1.RemoveItem 0
  457.     'This creates the first folder. First the column is addressed, then it is added,
  458.     'then the item is added. Note the .AddItem method requires that an index
  459.     'be set for the item.
  460.     MhTree1.Column = 0
  461.     MhTree1.AddItemColumn = 0
  462.     MhTree1.AddItem "Trunk", 0
  463.     'This creates second folder.
  464.     MhTree1.Column = 1
  465.     MhTree1.AddItemColumn = 1
  466.     MhTree1.AddItem "Branch 1", 1
  467.     'This creates the third folder
  468.     MhTree1.Column = 1
  469.     MhTree1.AddItemColumn = 1
  470.     MhTree1.AddItem "Branch 2", 2
  471.     MhTree1.Column = 2
  472.     MhTree1.AddItemColumn = 2
  473.     MhTree1.AddItem "Sub Branch 1", 3
  474.     MhTree1.AddItem "Sub Branch 2", 4
  475.     MhTree1.AddItem "Sub Branch 3", 5
  476.     'This creates the fourth folder
  477.     MhTree1.Column = 1
  478.     MhTree1.AddItemColumn = 1
  479.     MhTree1.AddItem "Branch 3", 6
  480.     MhTree1.Column = 2
  481.     MhTree1.AddItemColumn = 2
  482.     MhTree1.AddItem "Sub Branch 4", 7
  483.     MhTree1.AddItem "Sub Branch 5", 8
  484.     MhTree1.AddItem "Sub Branch 6", 9
  485.     'This creates the Fifth folder
  486.     MhTree1.Column = 1
  487.     MhTree1.AddItemColumn = 1
  488.     MhTree1.AddItem "Branch 4", 10
  489.     MhTree1.Column = 2
  490.     MhTree1.AddItemColumn = 2
  491.     MhTree1.AddItem "Sub Branch 7", 11
  492.     MhTree1.AddItem "Sub Branch 8", 12
  493.     MhTree1.AddItem "Sub Branch 9", 13
  494.     MhTree1.AddItem "Sub Branch 10", 14
  495.     MhTree1.AddItem "Sub Branch 11", 15
  496.     MhTree1.AddItem "Sub Branch 12", 16
  497.     'This creates the sixth folder
  498.     MhTree1.Column = 1
  499.     MhTree1.AddItemColumn = 1
  500.     MhTree1.AddItem "Branch 5", 17
  501.     MhTree1.Column = 2
  502.     MhTree1.AddItemColumn = 2
  503.     MhTree1.ListPicture(15) = MhTree1.Loadedpicture(1)
  504.     MhTree1.ListPictureSel(15) = MhTree1.Loadedpicture(3)
  505.     MhTree1.AddItem "Sub Branch 13", 18
  506.     MhTree1.AddItem "Sub Branch 14", 19
  507.     MhTree1.AddItem "Sub Branch 15", 20
  508.     MhTree1.Column = 3
  509.     MhTree1.AddItemColumn = 3
  510.     MhTree1.AddItem "Sub Sub Branch 16", 21
  511.     MhTree1.AddItem "Sub Sub Branch 17", 22
  512.     MhTree1.AddItem "Sub Sub Branch 18", 23
  513.     MhTree1.AddItem "Sub Sub Branch 19", 24
  514.     MhTree1.AddItem "Sub Sub Branch 20", 25
  515.     MhTree1.AddItem "And so forth . . .", 26
  516. End Sub
  517. Private Sub itmBevel_Click(Index As Integer)
  518. 'This will set a bevel size based on the user's choice
  519.     Dim iIndex As Integer
  520.     'Uncheck menu items
  521.     For iIndex = 0 To 2
  522.         itmBevel(iIndex).Checked = False
  523.     Next
  524.     'Make selection and check menu. We change color to highlight the selection
  525.     'so it will be easier to see now that the bevel is removed. We do the refresh
  526.     'in case the user has a currently selected item. We want that item to
  527.     'reflect the change they've made.
  528.     Select Case Index
  529.         Case im_NONE
  530.             itmStyle(0).Checked = False
  531.             itmStyle(1).Checked = False
  532.             MhTree1.BevelSizeInner = im_NONE
  533.             MhTree1.FillColor = im_WHITE
  534.             MhTree1.SelectedColor = &H8000000D
  535.             MhTree1.Refresh
  536.         'Value chosen because it looks best. Change .SelectedColor so visual effect
  537.         'of bevel will be highlighted
  538.         Case im_SMALL
  539.             MhTree1.BevelSizeInner = 2
  540.             itmStyle(im_LOWERED).Checked = True
  541.             MhTree1.FillColor = &HC0C0C0
  542.             MhTree1.SelectedColor = &HC0C0C0
  543.             MhTree1.Refresh
  544.         'Value best illustrates .LightColor, .ShadowColor properties
  545.         Case im_LARGE
  546.             MhTree1.BevelSizeInner = 5
  547.             itmStyle(im_RAISED).Checked = True
  548.             MhTree1.FillColor = &HC0C0C0
  549.             MhTree1.SelectedColor = &HC0C0C0
  550.             MhTree1.Refresh
  551.     End Select
  552.     itmBevel(Index).Checked = True
  553. End Sub
  554. Private Sub itmColColor_Click(Index As Integer)
  555. 'Routine calls up common color dialog so we can
  556. 'illustrate the color properties of the control.
  557.     MhTree1.Column = 1
  558.     'Sets flag to prevent custom color palette from
  559.     'appearing, calls dialog and sets appropriate
  560.     'color property when dialog closes.
  561.     MhCommonDialog1.Flags = CC_PREVENTFULLOPEN
  562.     MhCommonDialog1.CancelError = True
  563.     On Error GoTo ColColorError
  564.     MhCommonDialog1.Action = 3
  565.     Select Case Index
  566.         Case im_COLBACKCOLOR
  567.             MhTree1.ColBackColor = MhCommonDialog1.Color
  568.         Case im_COLFORECOLOR
  569.             MhTree1.ColForeColor = MhCommonDialog1.Color
  570.         Case im_COLHIGHCOLOR
  571.             MhTree1.ColHighColor = MhCommonDialog1.Color
  572.     End Select
  573. Exit Sub
  574. ColColorError:
  575.     Select Case Index
  576.         Case im_COLBACKCOLOR
  577.             MhTree1.ColBackColor = MhTree1.ColBackColor
  578.         Case im_COLFORECOLOR
  579.             MhTree1.ColForeColor = MhTree1.ColForeColor
  580.         Case im_COLHIGHCOLOR
  581.             MhTree1.ColHighColor = MhTree1.ColHighColor
  582.     End Select
  583.     Exit Sub
  584. End Sub
  585. Private Sub itmDirectory_Click()
  586. 'This will place a list of all the directories
  587. 'on your disk in the MhTree1. As always, first we clear the MhTree1,
  588. 'then set ListCount.
  589.     MhTree1.ClearBox = 0
  590.     MhTree1.ListCount = 1000
  591.     ChDir "c:\"
  592.     MhTree1.Dir = True
  593.     'This causes the box to list the directories
  594.     MhTree1.FileList = True
  595.     'This causes the current directory to appear as the trunk of the MhTree1
  596.     MhTree1.List(0) = CurDir
  597. End Sub
  598. Private Sub itmExit_Click()
  599. 'Dump form, end
  600.     Unload fMhTree
  601.     End
  602. End Sub
  603. Private Sub itmGlobalColor_Click(Index As Integer)
  604. 'Routine calls up common color dialog so we can
  605. 'illustrate the color properties of the control.
  606.     'Sets flag to prevent custom color palette from
  607.     'appearing, calls dialog and sets appropriate
  608.     'color property when dialog closes.
  609.     MhCommonDialog1.Flags = CC_PREVENTFULLOPEN
  610.     MhCommonDialog1.CancelError = True
  611.     On Error GoTo ColorError
  612.     MhCommonDialog1.Action = 3
  613.     Select Case Index
  614.         Case im_BORDERCOLOR
  615.             MhTree1.BorderColor = MhCommonDialog1.Color
  616.         Case im_FILLCOLOR
  617.             MhTree1.FillColor = MhCommonDialog1.Color
  618.         Case im_HIGHCOLOR
  619.             MhTree1.HighColor = MhCommonDialog1.Color
  620.         Case im_LIGHTCOLOR
  621.             MhTree1.LightColor = MhCommonDialog1.Color
  622.         Case im_LINECOLOR
  623.             MhTree1.LineColor = MhCommonDialog1.Color
  624.         Case im_SELECTEDCOLOR
  625.             MhTree1.SelectedColor = MhCommonDialog1.Color
  626.         Case im_SHADOWCOLOR
  627.             MhTree1.ShadowColor = MhCommonDialog1.Color
  628.         Case im_TEXTCOLOR
  629.             MhTree1.TextColor = MhCommonDialog1.Color
  630.     End Select
  631. Exit Sub
  632. ColorError:
  633.     Select Case Index
  634.         Case im_BORDERCOLOR
  635.             MhTree1.BorderColor = MhTree1.BorderColor
  636.         Case im_FILLCOLOR
  637.             MhTree1.FillColor = MhTree1.FillColor
  638.         Case im_HIGHCOLOR
  639.             MhTree1.HighColor = MhTree1.HighColor
  640.         Case im_LIGHTCOLOR
  641.             MhTree1.LightColor = MhTree1.LightColor
  642.         Case im_LINECOLOR
  643.             MhTree1.LineColor = MhTree1.LineColor
  644.         Case im_SELECTEDCOLOR
  645.             MhTree1.SelectedColor = MhTree1.SelectedColor
  646.         Case im_SHADOWCOLOR
  647.             MhTree1.ShadowColor = MhTree1.ShadowColor
  648.         Case im_TEXTCOLOR
  649.             MhTree1.TextColor = MhTree1.TextColor
  650.     End Select
  651.     Exit Sub
  652. End Sub
  653. Private Sub itmGroupColor_Click(Index As Integer)
  654. 'Routine calls up common color dialog so we can
  655. 'illustrate the color properties of the control.
  656.     If lstSelect.ListCount = 0 Then
  657.         MsgBox "These properties cannot be set until Group One is created. Select an item from the list and Click the " & Chr$(34) & "Add To Group One" & Chr$(34) & " button before trying to set these properties.", 16, "MicroHelp"
  658.         Exit Sub
  659.     End If
  660.     MhTree1.Group = 1
  661.     'Sets flag to prevent custom color palette from
  662.     'appearing, calls dialog and sets appropriate
  663.     'color property when dialog closes.
  664.     MhCommonDialog1.Flags = CC_PREVENTFULLOPEN
  665.     MhCommonDialog1.CancelError = True
  666.     On Error GoTo GroupColorError
  667.     MhCommonDialog1.Action = 3
  668.     Select Case Index
  669.         Case im_GROUPBACKCOLOR
  670.             MhTree1.GroupBackColor = MhCommonDialog1.Color
  671.         Case im_GROUPFORECOLOR
  672.             MhTree1.GroupForeColor = MhCommonDialog1.Color
  673.         Case im_GROUPHIGHCOLOR
  674.             MhTree1.GroupHighColor = MhCommonDialog1.Color
  675.     End Select
  676. Exit Sub
  677. GroupColorError:
  678.     Select Case Index
  679.         Case im_GROUPBACKCOLOR
  680.             MhTree1.GroupBackColor = MhTree1.GroupBackColor
  681.         Case im_GROUPFORECOLOR
  682.             MhTree1.GroupForeColor = MhTree1.GroupForeColor
  683.         Case im_GROUPHIGHCOLOR
  684.             MhTree1.GroupHighColor = MhTree1.GroupHighColor
  685.     End Select
  686.     Exit Sub
  687. End Sub
  688. Private Sub itmList_Click()
  689. 'The .List method populates the box also. Unlike the .AddItem method, the list
  690. 'will appear with only the root showing as opposed to showing every branch of
  691. 'the MhTree1.
  692.     'The .ClearBox property acts like a method to clear the box if set to 0
  693.     'Note, also, that .ListCount MUST be set prior to populating the tree. This
  694.     'is not the usual listbox property. It doesn't return info about how many items
  695.     'are in the tree; It sets a limit on how many items the tree can contain.
  696.     MhTree1.ClearBox = 0
  697.     MhTree1.ListCount = 100
  698.     MhTree1.DefaultPics = True
  699.     'You MUST set the number of columns and the widths of those columns.
  700.     'It's easiest to set the pictures for selected and unselected states
  701.     'on a per-column basis at the beginning of your routine. That way, you
  702.     'don't have to worry about setting each one.
  703.     'Note that this could also be done on a per-line basis using .ListPicture
  704.     'That's illustrated below.
  705.     MhTree1.Columns = 5
  706.     MhTree1.Column = 0
  707.     MhTree1.ColWidth = 10
  708.     MhTree1.ColPicture = MhTree1.Loadedpicture(1)
  709.     MhTree1.ColPictureSel = MhTree1.Loadedpicture(3)
  710.     MhTree1.Column = 1
  711.     MhTree1.ColWidth = 10
  712.     MhTree1.ColPicture = MhTree1.Loadedpicture(1)
  713.     MhTree1.ColPictureSel = MhTree1.Loadedpicture(3)
  714.     MhTree1.Column = 2
  715.     MhTree1.ColWidth = 10
  716.     MhTree1.ColPicture = MhTree1.Loadedpicture(5)
  717.     MhTree1.ColPictureSel = MhTree1.Loadedpicture(7)
  718.     MhTree1.Column = 3
  719.     MhTree1.ColWidth = 10
  720.     MhTree1.ColPicture = MhTree1.Loadedpicture(5)
  721.     MhTree1.ColPictureSel = MhTree1.Loadedpicture(7)
  722.     MhTree1.Column = 4
  723.     MhTree1.ColWidth = 10
  724.     MhTree1.ColPicture = MhTree1.Loadedpicture(5)
  725.     MhTree1.ColPictureSel = MhTree1.Loadedpicture(7)
  726.     'The following pattern is repeated over and over again.
  727.     'This sets the index and caption to 0
  728.     MhTree1.List(0) = "MhTree1 trunk"
  729.     'This adds the item at index 0 and puts it in column 0
  730.     MhTree1.ListColumn(0) = 0
  731.     'Notice now all values change to 1 because we move to index 1 and column 1
  732.     MhTree1.List(1) = "Branch 1 of trunk"
  733.     MhTree1.ListColumn(1) = 1
  734.     'Now all values change to 2 because we move to index 2 and column 2
  735.     MhTree1.List(2) = "Sub Branch 1"
  736.     MhTree1.ListColumn(2) = 2
  737.     'Now index changes to 3 but column remains at 2 because we're in the same column
  738.     'as the previous item.
  739.     MhTree1.List(3) = "Sub Branch 2"
  740.     MhTree1.ListColumn(3) = 2
  741.     MhTree1.List(4) = "Sub Branch 3"
  742.     MhTree1.ListColumn(4) = 2
  743.     MhTree1.List(5) = "Branch 2 of trunk"
  744.     MhTree1.ListColumn(5) = 1
  745.     MhTree1.List(6) = "Sub Branch 3"
  746.     MhTree1.ListColumn(6) = 2
  747.     MhTree1.List(7) = "Sub Branch 4"
  748.     MhTree1.ListColumn(7) = 2
  749.     'Here, we're adding some branches off this sub branch so we have
  750.     'change it's picture on a per-line basis since we want the rest of
  751.     'the items to have the default document-type artwork.
  752.     MhTree1.ListPicture(8) = MhTree1.Loadedpicture(1)
  753.     MhTree1.ListPictureSel(8) = MhTree1.Loadedpicture(3)
  754.     MhTree1.List(8) = "Sub Branch 5"
  755.     MhTree1.ListColumn(8) = 2
  756.     MhTree1.List(9) = "Sub Sub Branch 1"
  757.     MhTree1.ListColumn(9) = 3
  758.     MhTree1.List(10) = "Sub Sub Branch 2"
  759.     MhTree1.ListColumn(10) = 3
  760.     MhTree1.List(11) = "Sub Sub Branch 1"
  761.     MhTree1.ListColumn(11) = 3
  762.     MhTree1.List(12) = "Sub Sub Branch 2"
  763.     MhTree1.ListColumn(12) = 3
  764.     MhTree1.List(13) = "Sub Sub Branch 1"
  765.     MhTree1.ListColumn(13) = 3
  766.     MhTree1.List(14) = "Sub Sub Branch 2"
  767.     MhTree1.ListColumn(14) = 3
  768.     MhTree1.ListPicture(15) = MhTree1.Loadedpicture(1)
  769.     MhTree1.ListPictureSel(15) = MhTree1.Loadedpicture(3)
  770.     MhTree1.List(15) = "Sub Sub Branch 3"
  771.     MhTree1.ListColumn(15) = 3
  772.     MhTree1.List(16) = "Sub Sub Sub Branch 1"
  773.     MhTree1.ListColumn(16) = 4
  774.     MhTree1.List(17) = "Sub Sub Sub Branch 2"
  775.     MhTree1.ListColumn(17) = 4
  776.     MhTree1.List(18) = "Sub Sub Sub Branch 3"
  777.     MhTree1.ListColumn(18) = 4
  778.     MhTree1.List(19) = "Sub Sub Sub Branch 4"
  779.     MhTree1.ListColumn(19) = 4
  780.     MhTree1.List(20) = "Sub Sub Sub Branch 5"
  781.     MhTree1.ListColumn(20) = 4
  782.     MhTree1.List(21) = "I suppose you could keep this up all day if you wanted to."
  783.     MhTree1.ListColumn(21) = 4
  784. End Sub
  785. Private Sub itmListColor_Click(Index As Integer)
  786. 'Routine calls up common color dialog so we can
  787. 'illustrate the color properties of the control.
  788.     'Sets flag to prevent custom color palette from
  789.     'appearing, calls dialog and sets appropriate
  790.     'color property when dialog closes.
  791.     MhCommonDialog1.Flags = CC_PREVENTFULLOPEN
  792.     MhCommonDialog1.CancelError = True
  793.     On Error GoTo ListColorError
  794.     MhCommonDialog1.Action = 3
  795.     Select Case Index
  796.         Case im_LISTBACKCOLOR
  797.             MhTree1.ListBackColor(MhTree1.ListIndex) = MhCommonDialog1.Color
  798.         Case im_LISTFORECOLOR
  799.             MhTree1.ListForeColor(MhTree1.ListIndex) = MhCommonDialog1.Color
  800.         Case im_LISTHIGHCOLOR
  801.             MhTree1.ListHighColor(MhTree1.ListIndex) = MhCommonDialog1.Color
  802.     End Select
  803. Exit Sub
  804. ListColorError:
  805.     Select Case Index
  806.         Case im_LISTBACKCOLOR
  807.             MhTree1.ListBackColor(MhTree1.ListIndex) = MhTree1.ListBackColor(MhTree1.ListIndex)
  808.         Case im_LISTFORECOLOR
  809.             MhTree1.ListForeColor(MhTree1.ListIndex) = MhTree1.ListForeColor(MhTree1.ListIndex)
  810.         Case im_LISTHIGHCOLOR
  811.             MhTree1.ListHighColor(MhTree1.ListIndex) = MhTree1.ListHighColor(MhTree1.ListIndex)
  812.     End Select
  813.     Exit Sub
  814. End Sub
  815. Private Sub itmMultiSelect_Click()
  816. 'Determines whether the tree will be set
  817. 'for multiple or single selection. Note that
  818. 'changing this at runtime will cause the tree
  819. 'to be cleared.
  820.     If MhTree1.ExtendedSelect = False Then
  821.         MhTree1.SingleSelect = False
  822.         MhTree1.ExtendedSelect = True
  823.         itmMultiSelect.Caption = "Single Selection"
  824.         itmAddItem_Click
  825.         MsgBox "Note that changing this property at runtime clears the tree and requires that it be refilled.", 16, "MicroHelp"
  826.     Else
  827.         MhTree1.SingleSelect = True
  828.         MhTree1.ExtendedSelect = False
  829.         itmMultiSelect.Caption = "Extended Selection"
  830.         itmAddItem_Click
  831.         MsgBox "Note that changing this property at runtime clears the tree and requires that it be refilled.", 16, "MicroHelp"
  832.     End If
  833. End Sub
  834. Private Sub itmPictures_Click()
  835.     MhTree1.Group = 0
  836.     MhTree1.FileList = False
  837.     MhTree1.DefaultPics = True
  838.     MhTree1.ClearBox = 0
  839.     MhTree1.ListCount = 50
  840.     MhTree1.List(0) = "Default pictures"
  841.     MhTree1.ListColumn(0) = 0
  842.     MhTree1.List(1) = ".LoadedPicture(0)"
  843.     MhTree1.ListPicture(1) = MhTree1.Loadedpicture(0)
  844.     MhTree1.ListPictureSel(1) = MhTree1.Loadedpicture(0)
  845.     MhTree1.ListColumn(1) = 1
  846.     MhTree1.List(2) = ".LoadedPicture(1)"
  847.     MhTree1.ListPicture(2) = MhTree1.Loadedpicture(1)
  848.     MhTree1.ListPictureSel(2) = MhTree1.Loadedpicture(1)
  849.     MhTree1.ListColumn(2) = 1
  850.     MhTree1.List(3) = ".LoadedPicture(2)"
  851.     MhTree1.ListPicture(3) = MhTree1.Loadedpicture(2)
  852.     MhTree1.ListPictureSel(3) = MhTree1.Loadedpicture(2)
  853.     MhTree1.ListColumn(3) = 1
  854.     MhTree1.List(4) = ".LoadedPicture(3)"
  855.     MhTree1.ListPicture(4) = MhTree1.Loadedpicture(3)
  856.     MhTree1.ListPictureSel(4) = MhTree1.Loadedpicture(3)
  857.     MhTree1.ListColumn(4) = 1
  858.     MhTree1.List(5) = ".LoadedPicture(4)"
  859.     MhTree1.ListPicture(5) = MhTree1.Loadedpicture(4)
  860.     MhTree1.ListPictureSel(5) = MhTree1.Loadedpicture(4)
  861.     MhTree1.ListColumn(5) = 1
  862.     MhTree1.List(6) = ".LoadedPicture(5)"
  863.     MhTree1.ListPicture(6) = MhTree1.Loadedpicture(5)
  864.     MhTree1.ListPictureSel(6) = MhTree1.Loadedpicture(5)
  865.     MhTree1.ListColumn(6) = 1
  866.     MhTree1.List(7) = ".LoadedPicture(6)"
  867.     MhTree1.ListPicture(7) = MhTree1.Loadedpicture(6)
  868.     MhTree1.ListPictureSel(7) = MhTree1.Loadedpicture(6)
  869.     MhTree1.ListColumn(7) = 1
  870.     MhTree1.List(8) = ".LoadedPicture(7)"
  871.     MhTree1.ListPicture(8) = MhTree1.Loadedpicture(7)
  872.     MhTree1.ListPictureSel(8) = MhTree1.Loadedpicture(7)
  873.     MhTree1.ListColumn(8) = 1
  874.     MhTree1.List(9) = ".LoadedPicture(8)"
  875.     MhTree1.ListPicture(9) = MhTree1.Loadedpicture(8)
  876.     MhTree1.ListPictureSel(9) = MhTree1.Loadedpicture(8)
  877.     MhTree1.ListColumn(9) = 1
  878.     MhTree1.List(10) = ".LoadedPicture(9)"
  879.     MhTree1.ListPicture(10) = MhTree1.Loadedpicture(9)
  880.     MhTree1.ListPictureSel(10) = MhTree1.Loadedpicture(9)
  881.     MhTree1.ListColumn(10) = 1
  882.     MhTree1.List(11) = ".LoadedPicture(10)"
  883.     MhTree1.ListPicture(11) = MhTree1.Loadedpicture(10)
  884.     MhTree1.ListPictureSel(11) = MhTree1.Loadedpicture(10)
  885.     MhTree1.ListColumn(11) = 1
  886.     MhTree1.List(12) = ".LoadedPicture(11)"
  887.     MhTree1.ListPicture(12) = MhTree1.Loadedpicture(11)
  888.     MhTree1.ListPictureSel(12) = MhTree1.Loadedpicture(11)
  889.     MhTree1.ListColumn(12) = 1
  890.     MhTree1.List(13) = ".LoadedPicture(12)"
  891.     MhTree1.ListPicture(13) = MhTree1.Loadedpicture(12)
  892.     MhTree1.ListPictureSel(13) = MhTree1.Loadedpicture(12)
  893.     MhTree1.ListColumn(13) = 1
  894.     MhTree1.List(14) = ".LoadedPicture(13)"
  895.     MhTree1.ListPicture(14) = MhTree1.Loadedpicture(13)
  896.     MhTree1.ListPictureSel(14) = MhTree1.Loadedpicture(13)
  897.     MhTree1.ListColumn(14) = 1
  898.     MhTree1.List(15) = ".LoadedPicture(14)"
  899.     MhTree1.ListPicture(15) = MhTree1.Loadedpicture(14)
  900.     MhTree1.ListPictureSel(15) = MhTree1.Loadedpicture(14)
  901.     MhTree1.ListColumn(15) = 1
  902.     MhTree1.Expand = 1
  903. End Sub
  904. Private Sub itmSizeable_Click()
  905. 'Makes the tree sizeable
  906.     If MhTree1.Sizeable = False Then
  907.         MhTree1.Sizeable = True
  908.         itmSizeable.Caption = "Non-Sizeable"
  909.     Else
  910.         MhTree1.Sizeable = False
  911.         itmSizeable.Caption = "Sizeable"
  912.     End If
  913. End Sub
  914. Private Sub itmStyle_Click(Index As Integer)
  915. 'Set bevel style
  916.     'Kicks user out if they have bevel set to none
  917.     If MhTree1.BevelSizeInner = im_NONE Then
  918.         MsgBox "In order to set a bevel style, first set a bevel size.", 16, "MicroHelp"
  919.         Exit Sub
  920.     End If
  921.     'Turn off checks
  922.     itmStyle(0).Checked = False
  923.     itmStyle(1).Checked = False
  924.     Select Case Index
  925.         Case 0
  926.             MhTree1.BevelStyleInner = im_LOWERED
  927.             itmStyle(Index).Checked = True
  928.             MhTree1.Refresh
  929.         Case 1
  930.             MhTree1.BevelStyleInner = im_RAISED
  931.             itmStyle(Index).Checked = True
  932.             MhTree1.Refresh
  933.     End Select
  934. End Sub
  935. Private Sub MhTree1_KeyUp(keycode As Integer, Shift As Integer)
  936. 'Expands, contracts list items when you hit enter key or spacebar
  937. 'Note that you could programmatically open any folder by setting the
  938. '.ListExpand property for that folder's .ListIndex
  939.     If keycode = 32 Then
  940.         If MhTree1.ListExpand(MhTree1.ListIndex) = False Then
  941.             MhTree1.ListExpand(MhTree1.ListIndex) = True
  942.         Else
  943.             MhTree1.ListExpand(MhTree1.ListIndex) = False
  944.         End If
  945.     End If
  946. End Sub
  947.