home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / axtree / axtree.old < prev    next >
Encoding:
Text File  |  1998-08-26  |  40.1 KB  |  1,077 lines

  1. Attribute VB_Name = "otlcb95bas"
  2. Option Explicit
  3. Option Base 1
  4.  
  5. 'OTL variables
  6. Public Type OtlSetup 'one per outline
  7.     Levels As Integer
  8.     VariableNames(5) As String 'Max 5 levels
  9.     BmpField As String 'field holding bitmap to use for leafs if not use default
  10.     CheckmarkField As String 'field to examine to determine if record is selected
  11.     BmpFlag As Integer
  12.     LineFlag As Integer
  13.     PlusFlag As Integer
  14.     CheckmarkFlag As Integer
  15.     AutoCheckParents As Integer
  16.     DisplayLines As Integer
  17.     DisplayIdx(100) As Integer 'Max 100 lines visible
  18.     DisplayCount As Integer 'virtual Ubound of displayidx
  19.     VisibleItems As Integer
  20.     VisChangeFlag As Integer
  21.     LineHeight As Integer 'Twips
  22.     ColWidth As Integer 'twips
  23.     ElementClicked As Integer
  24.     SelectColor As Long 'RGB
  25.     SelectTextColor As Long
  26.     FontName As String
  27.     FontColor As Long
  28.     Fontsize As Single
  29.     TopIdx As Integer
  30.     SelectIdx As Integer
  31.     CurrentLine As Integer
  32.     PrevTop As Integer
  33.     PrevSel As Integer
  34.     LastType As Integer     ' 0=None, 1=Parent, 2=Collapse, 3=Expand, 4=Child, Last clicked or keypress
  35. End Type
  36.  
  37. Public Type OtlData  'Use in array
  38.     Caption As String
  39.     Level As Integer
  40.     Visible As Integer
  41.     Expanded As Integer
  42.     VisibleIdx As Long
  43.     Bookmark As String
  44.     Bitmap As Picture 'if not use default
  45.     Selected As Integer '0-none, 1-all, 2-some
  46.     SyncIdx As Integer 'Optional, sync to another array
  47.     Itemdata As Long
  48.     IsParent As Boolean 'is this a parent
  49. End Type
  50.  
  51. 'standard images
  52. Global gBranchOpenPic As Control
  53. Global gBranchClosedPic As Control
  54. Global gLeafPic As Control
  55. Global gCustomPic As Control
  56. Global gPlusPic As Control
  57. Global gMinusPic As Control
  58. 'checked images
  59. Global gBranchOpenAllPic As Control 'checked
  60. Global gBranchClosedAllPic As Control
  61. Global gBranchOpenSomePic As Control
  62. Global gBranchClosedSomePic As Control
  63. Global gLeafCheckedPic As Control
  64. Dim ChangingScroll As Integer
  65.  
  66. 'KeyCodes Constants
  67. Const KEY_PRIOR = &H21
  68. Const KEY_NEXT = &H22
  69. Const KEY_END = &H23
  70. Const KEY_HOME = &H24
  71. Const KEY_LEFT = &H25
  72. Const KEY_UP = &H26
  73. Const KEY_RIGHT = &H27
  74. Const KEY_DOWN = &H28
  75. Const KEY_ADD = &H6B
  76. Const KEY_SUBTRACT = &H6D
  77.  
  78. #If Win32 Then
  79.     Declare Function BitBlt Lib "gdi32" (ByVal hDestDC%, ByVal x%, ByVal y%, ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal xSrc%, ByVal ySrc%, ByVal dwRop&) As Integer
  80.     Declare Function StretchBlt Lib "gdi32" (ByVal hDestDC%, ByVal x%, ByVal y%, ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal xSrc%, ByVal ySrc%, ByVal nsrcWidth%, ByVal nsrcHeight%, ByVal dwRop&) As Integer
  81.     Declare Function SetPixel Lib "gdi32" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
  82. #Else
  83.     Declare Function BitBlt Lib "GDI" (ByVal hDestDC%, ByVal x%, ByVal y%, ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal xSrc%, ByVal ySrc%, ByVal dwRop&) As Integer
  84.     Declare Function StretchBlt Lib "GDI" (ByVal hDestDC%, ByVal x%, ByVal y%, ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal xSrc%, ByVal ySrc%, ByVal nsrcWidth%, ByVal nsrcHeight%, ByVal dwRop&) As Integer
  85.     Declare Function SetPixel Lib "GDI" (ByVal hDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal crColor As Long) As Long
  86. #End If
  87.  
  88. 'Establishes the Bitmap objects for an outline control
  89. 'Sub OutlineBmpSetup(BranchOpen As Control, BoFile As String, BranchClosed As Control, BcFile As String, Leaf As Control, LFile As String, CustomPic As Control)
  90. 'On Error Resume Next
  91. '
  92. 'Set gBranchOpenPic = IIf(m_PictureOpen = Nothing, BranchOpen, m_PictureOpen)
  93. 'Set gBranchClosedPic = IIf(m_PictureClosed = Nothing, BranchClosed, m_PictureClosed)
  94. 'Set gLeafPic = IIf(m_PictureItemNotSelected = Nothing, Leaf, m_PictureItemNotSelected)
  95. 'Set gCustomPic = IIf(m_PictureItemNotSelected = Nothing, CustomPic, m_PictureItemNotSelected)
  96. '
  97. 'If BoFile > "" Then gBranchOpenPic.Picture = LoadPicture(BoFile)
  98. 'If BcFile > "" Then gBranchClosedPic.Picture = LoadPicture(BcFile)
  99. 'If LFile > "" Then gLeafPic.Picture = LoadPicture(LFile)
  100. '
  101. 'End Sub
  102. Sub OutlineBmpSetup(BranchOpen As Control, BoPic As Picture, BranchClosed As Control, BcPic As Picture, Leaf As Control, LPic As Picture, CustomPic As Control, CPic As Picture)
  103. On Error Resume Next
  104.  
  105. Set gBranchOpenPic = BranchOpen
  106. Set gBranchClosedPic = BranchClosed
  107. Set gLeafPic = Leaf
  108. Set gCustomPic = CustomPic
  109.  
  110. If Not BoPic Is Nothing Then gBranchOpenPic.Picture = BoPic
  111. If Not BcPic Is Nothing Then gBranchClosedPic.Picture = BcPic
  112. If Not LPic Is Nothing Then gLeafPic.Picture = LPic
  113. If Not CPic Is Nothing Then gCustomPic.Picture = CPic
  114.  
  115. End Sub
  116.  
  117. Sub OutlineBmpCheckedSetup(BranchOpenAll As Control, BoaPic As Picture, BranchClosedAll As Control, BcaPic As Picture, BranchOpenSome As Control, BosPic As Picture, BranchClosedSome As Control, BcsPic As Picture, LeafChecked As Control, LcPic As Picture)
  118. 'On Error Resume Next
  119.  
  120. Set gBranchOpenAllPic = BranchOpenAll
  121. Set gBranchClosedAllPic = BranchClosedAll
  122. Set gBranchOpenSomePic = BranchOpenSome
  123. Set gBranchClosedSomePic = BranchClosedSome
  124. Set gLeafCheckedPic = LeafChecked
  125.  
  126. If Not BoaPic Is Nothing Then gBranchOpenAllPic.Picture = BoaPic
  127. If Not BcaPic Is Nothing Then gBranchClosedAllPic.Picture = BcaPic
  128. If Not BosPic Is Nothing Then gBranchOpenSomePic.Picture = BosPic
  129. If Not BcsPic Is Nothing Then gBranchClosedSomePic.Picture = BcsPic
  130. If Not LcPic Is Nothing Then gLeafCheckedPic.Picture = LcPic
  131.  
  132.  
  133. End Sub
  134.  
  135.  
  136. 'Processes a mouse click.
  137. Sub OutlineClick(OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  138. Dim foo As Integer
  139. Dim Children As Integer
  140.  
  141. 'set select
  142. OtlSet.LastType = 0
  143. If OtlSet.CurrentLine > OtlSet.DisplayCount Then Exit Sub
  144.  
  145. 'default as child click, but change later if parent
  146. OtlSet.LastType = IIf(OtlSet.ElementClicked > 0, 4, 0)
  147.  
  148. 'If OtlSet.ElementClicked > 0 Then OtlSet.SelectIdx = OtlSet.DisplayIdx(OtlSet.CurrentLine)
  149. OtlSet.SelectIdx = OtlSet.DisplayIdx(OtlSet.CurrentLine)
  150.  
  151. 'if pictureclick then select all or deselect all, don't expand
  152. If OtlSet.ElementClicked = 1 And OtlSet.CheckmarkFlag Then
  153.   If Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).IsParent Then
  154.     OtlSet.LastType = 1
  155.   Else
  156.     OtlSet.LastType = 4
  157.   End If
  158.   OtlSet.VisChangeFlag = True
  159.   If Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Selected = 1 Then
  160.     Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Selected = 0
  161.   Else
  162.     Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Selected = 1
  163.   End If
  164.  
  165.   If OtlSet.AutoCheckParents Then
  166.     'set child select
  167.     For foo = OtlSet.DisplayIdx(OtlSet.CurrentLine) + 1 To Otldat.Count
  168.       If Otldat(foo).Level <= Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Level Then Exit For
  169.       Otldat(foo).Selected = Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Selected
  170.     Next foo
  171.     'set parent selects
  172.     CheckMarkParents OtlSet, Otldat
  173.   End If
  174. Else
  175.   'is it a branch?
  176.   'If OtlDat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Level < OtlSet.Levels - 1 Then
  177.   If Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).IsParent Then
  178.   
  179.       OtlSet.VisChangeFlag = True
  180.       'was it expanded?
  181.       If Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Expanded = True Then
  182.           'Collapse children
  183.           OtlSet.LastType = 2
  184.           For foo = OtlSet.DisplayIdx(OtlSet.CurrentLine) + 1 To Otldat.Count
  185.               If Otldat(foo).Level <= Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Level Then Exit For
  186.               Otldat(foo).Expanded = False
  187.               Otldat(foo).Visible = False
  188.           Next foo
  189.       Else
  190.           'Expand next level
  191.           OtlSet.LastType = 3
  192.           Children = 0
  193.           For foo = OtlSet.DisplayIdx(OtlSet.CurrentLine) + 1 To Otldat.Count
  194.               If Otldat(foo).Level <= Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Level Then
  195.                   Exit For
  196.               Else
  197.                   If Otldat(foo).Level = Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Level + 1 Then
  198.                       Otldat(foo).Expanded = False
  199.                       Otldat(foo).Visible = True
  200.                       Children = Children + 1
  201.                   End If
  202.               End If
  203.           Next foo
  204.       End If
  205.       Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Expanded = Not Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Expanded
  206.       If Children + OtlSet.CurrentLine >= OtlSet.DisplayLines Then
  207.         If Children < OtlSet.DisplayLines Then
  208.           OtlSet.TopIdx = OtlSet.DisplayIdx((OtlSet.CurrentLine + Children + 1) - OtlSet.DisplayLines)
  209.           OtlSet.SelectIdx = OtlSet.DisplayIdx(OtlSet.CurrentLine)
  210.           OtlSet.CurrentLine = OtlSet.CurrentLine - (Children + 1)
  211.         Else
  212.           OtlSet.TopIdx = OtlSet.DisplayIdx(OtlSet.CurrentLine)
  213.           OtlSet.SelectIdx = OtlSet.DisplayIdx(OtlSet.CurrentLine)
  214.           OtlSet.CurrentLine = 1
  215.         End If
  216.           
  217.       End If
  218.      
  219.   End If
  220. End If
  221. OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  222.  
  223. End Sub
  224.  
  225. Public Sub OutlineExpand(Index As Integer, OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  226. Dim foo As Integer
  227. Dim Children As Integer
  228.  
  229. 'set select
  230. OtlSet.LastType = 0
  231. OtlSet.SelectIdx = Index
  232.   
  233.   If Otldat(Index).IsParent Then
  234.   
  235.       OtlSet.VisChangeFlag = True
  236.       'was it expanded?
  237.       If Otldat(Index).Expanded = False Then
  238.           'Expand next level
  239.           OtlSet.LastType = 3
  240.           Children = 0
  241.           For foo = Index + 1 To Otldat.Count
  242.               If Otldat(foo).Level <= Otldat(Index).Level Then
  243.                   Exit For
  244.               Else
  245.                   If Otldat(foo).Level = Otldat(Index).Level + 1 Then
  246.                       Otldat(foo).Expanded = False
  247.                       Otldat(foo).Visible = True
  248.                       Children = Children + 1
  249.                   End If
  250.               End If
  251.           Next foo
  252.       
  253.       Otldat(Index).Expanded = True
  254.       If Children + Index >= OtlSet.DisplayLines Then
  255.         If Children < OtlSet.DisplayLines Then
  256.           OtlSet.TopIdx = (Index + Children + 1) - OtlSet.DisplayLines
  257.           OtlSet.SelectIdx = Index
  258.           Index = Index - (Children + 1)
  259.         Else
  260.           OtlSet.TopIdx = Index
  261.           OtlSet.SelectIdx = Index
  262.           OtlSet.CurrentLine = 1
  263.         End If  'if children
  264.       End If
  265.       End If
  266.      
  267.   End If
  268. OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  269.  
  270. End Sub
  271.  
  272. Public Sub OutlineCollapse(Index As Integer, OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  273. Dim foo As Integer
  274. Dim Children As Integer
  275.  
  276. 'set select
  277. OtlSet.LastType = 0
  278. OtlSet.SelectIdx = Index
  279.   
  280.   If Otldat(Index).IsParent Then
  281.   
  282.       OtlSet.VisChangeFlag = True
  283.       'was it expanded?
  284.       If Otldat(Index).Expanded = True Then
  285.           'Collapse children
  286.           OtlSet.LastType = 2
  287.           For foo = Index + 1 To Otldat.Count
  288.               If Otldat(foo).Level <= Otldat(Index).Level Then Exit For
  289.               Otldat(foo).Expanded = False
  290.               Otldat(foo).Visible = False
  291.           Next foo
  292.       
  293.           Otldat(Index).Expanded = False
  294.           OtlSet.TopIdx = Index
  295.           OtlSet.SelectIdx = Index
  296.           OtlSet.CurrentLine = 1
  297.       End If
  298.      
  299.   End If
  300. OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  301.  
  302. End Sub
  303.  
  304. Public Sub CheckMarkParents(OtlSet As OtlSetup, Otldat As CollectionEx)
  305. Dim foo As Integer
  306. ReDim LevelValue(OtlSet.Levels) As Double
  307. ReDim levelcount(OtlSet.Levels) As Integer
  308. For foo = Otldat.Count To 1 Step -1
  309.   'handle control break if this is not a child
  310. '  If OtlDat(foo).Level <= OtlSet.Levels - 2 Then
  311.   If Otldat(foo).IsParent Then
  312.     If LevelValue(Otldat(foo).Level + 1) = 0 Then
  313.       Otldat(foo).Selected = 0  'none selected
  314.     Else
  315.       If levelcount(Otldat(foo).Level + 1) = LevelValue(Otldat(foo).Level + 1) Then
  316.         Otldat(foo).Selected = 1  'all selected
  317.       Else
  318.         Otldat(foo).Selected = 2  'some selected
  319.       End If
  320.     End If
  321.     LevelValue(Otldat(foo).Level + 1) = 0
  322.     levelcount(Otldat(foo).Level + 1) = 0
  323.   End If
  324.   If Otldat(foo).Level > 0 Then
  325.     'increment parent count
  326.     Select Case Otldat(foo).Selected
  327.     Case 1
  328.       LevelValue(Otldat(foo).Level) = LevelValue(Otldat(foo).Level) + 1
  329.     Case 2
  330.       LevelValue(Otldat(foo).Level) = LevelValue(Otldat(foo).Level) + 0.0001
  331.     End Select
  332.     levelcount(Otldat(foo).Level) = levelcount(Otldat(foo).Level) + 1
  333.     
  334.   End If
  335. Next foo
  336. End Sub
  337.  
  338. 'Closes all open branches.
  339.  
  340. Sub OutlineCollapseAll(OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  341. Dim foo As Integer
  342. Dim TotVisible As Integer
  343. For foo = 1 To Otldat.Count
  344.     If Otldat(foo).Level > 0 Then
  345.         Otldat(foo).Visible = False
  346.         Otldat(foo).Expanded = False
  347.     Else
  348.         Otldat(foo).Expanded = False
  349.     End If
  350.     If Otldat(foo).Visible = True Then TotVisible = TotVisible + 1
  351. Next foo
  352. If Otldat(OtlSet.SelectIdx).Visible = False Then OtlSet.SelectIdx = 1
  353. If TotVisible <= OtlSet.DisplayLines Then
  354.   OtlSet.TopIdx = 1
  355. Else
  356.   OtlSet.TopIdx = OtlSet.SelectIdx
  357. End If
  358. OtlSet.VisChangeFlag = True
  359. OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  360.  
  361. End Sub
  362.  
  363.  
  364. 'Opens all branches.
  365.  
  366. Sub OutlineExpandAll(OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  367. Dim foo As Integer
  368.  
  369. For foo = 1 To Otldat.Count
  370.     Otldat(foo).Visible = True
  371.     'If OtlDat(foo).Level < OtlSet.Levels - 1 Then OtlDat(foo).Expanded = True
  372.     If Otldat(foo).IsParent Then Otldat(foo).Expanded = True
  373. Next foo
  374. OtlSet.VisChangeFlag = True
  375. OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  376.  
  377. End Sub
  378.  
  379.  
  380. 'Locates text within the control.
  381.  
  382. Sub OutlineFind(FindItem As String, FindMode As Integer, OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  383. Dim ItemStart As Integer, foo As Integer, foobar As Integer
  384. Dim foo2 As Integer
  385. If FindMode = 0 Then
  386.     ItemStart = 1
  387. Else
  388.     ItemStart = OtlSet.SelectIdx + 1
  389. End If
  390. For foo = ItemStart To Otldat.Count
  391.     If InStr(1, Otldat(foo).Caption, FindItem, 1) > 0 Then
  392.         OtlSet.SelectIdx = foo
  393.         OtlSet.TopIdx = foo
  394.         If Otldat(foo).Level <> 0 Then
  395.             For foobar = foo To 1 Step -1
  396.                 If Otldat(foobar).Level = 0 Then
  397.                     Otldat(foobar).Expanded = True
  398.                     Otldat(foobar).Visible = True
  399.                     Exit For
  400.                 End If
  401.             Next foobar
  402.             For foo2 = foobar + 1 To Otldat.Count
  403.                 If Otldat(foo2).Level = 0 Then Exit For
  404.                 Otldat(foo2).Visible = True
  405.             Next foo2
  406.         End If
  407.         OtlSet.CurrentLine = 1
  408.         OtlSet.VisChangeFlag = True
  409.         OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  410.         Exit Sub
  411.     End If
  412. Next foo
  413. 'item not found
  414. Beep
  415.  
  416. End Sub
  417.  
  418. 'goto a specific node
  419.  
  420. Sub OutlineGoto(FindItem As Integer, OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  421. Dim foo As Integer, foobar As Integer
  422. Dim foo2 As Integer
  423.         
  424. foo = FindItem
  425. If foo <= Otldat.Count Then
  426.         OtlSet.SelectIdx = foo
  427.         OtlSet.TopIdx = foo
  428.         If Otldat(foo).Level <> 0 Then
  429.             For foobar = foo To 1 Step -1
  430.                 If Otldat(foobar).Level = 0 Then
  431.                     Otldat(foobar).Expanded = True
  432.                     Otldat(foobar).Visible = True
  433.                     Exit For
  434.                 End If
  435.             Next foobar
  436.             For foo2 = foobar + 1 To Otldat.Count
  437.                 If Otldat(foo2).Level = 0 Then Exit For
  438.                 Otldat(foo2).Visible = True
  439.             Next foo2
  440.         End If
  441.         OtlSet.CurrentLine = 1
  442.         OtlSet.VisChangeFlag = True
  443.         OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  444. Else
  445.   Beep
  446. End If
  447. End Sub
  448.  
  449.  
  450. 'Processes outline control keys
  451.  
  452. Sub OutlineKeyPress(KeyCode As Integer, OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  453. Dim foo As Integer, VisCount As Integer
  454. On Error Resume Next
  455. Select Case KeyCode
  456.  
  457. Case vbKeyReturn
  458.     OtlSet.ElementClicked = 2
  459.     OutlineClick OtlPic, OtlScroll, OtlSet, Otldat
  460.     
  461. Case vbKeySpace
  462.     OtlSet.ElementClicked = 1
  463.     OutlineClick OtlPic, OtlScroll, OtlSet, Otldat
  464.     
  465. Case KEY_PRIOR
  466.     VisCount = 0
  467.     foo = 0
  468.     For foo = OtlSet.TopIdx To 1 Step -1
  469.         If Otldat(foo).Visible = True Then VisCount = VisCount + 1
  470.         If VisCount = OtlSet.DisplayLines Then Exit For
  471.     Next foo
  472.     OtlSet.CurrentLine = 1
  473.     OtlSet.TopIdx = foo + 1
  474.     OtlSet.SelectIdx = OtlSet.TopIdx
  475.     OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  476.  
  477. Case KEY_NEXT
  478.     For foo = OtlSet.DisplayLines To 1 Step -1
  479.         If OtlSet.DisplayIdx(foo) > 0 Then
  480.             OtlSet.TopIdx = OtlSet.DisplayIdx(foo)
  481.             Exit For
  482.         End If
  483.     Next foo
  484.     OtlSet.CurrentLine = 1
  485.     OtlSet.SelectIdx = OtlSet.TopIdx
  486.     OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  487.  
  488. Case KEY_END
  489.     OutlineGoto Otldat.Count, OtlPic, OtlScroll, OtlSet, Otldat
  490.     
  491. Case KEY_HOME
  492.     OutlineGoto 1, OtlPic, OtlScroll, OtlSet, Otldat
  493.  
  494. Case KEY_LEFT
  495.     OutlineCollapse OtlSet.SelectIdx, OtlPic, OtlScroll, OtlSet, Otldat
  496.     
  497. Case KEY_RIGHT
  498.     OutlineExpand OtlSet.SelectIdx, OtlPic, OtlScroll, OtlSet, Otldat
  499.  
  500. Case KEY_UP
  501.     If OtlSet.CurrentLine > 1 Then
  502.         OtlSet.CurrentLine = OtlSet.CurrentLine - 1
  503.         OtlSet.SelectIdx = OtlSet.DisplayIdx(OtlSet.CurrentLine)
  504.     Else
  505.         For foo = OtlSet.TopIdx - 1 To 1 Step -1
  506.             If Otldat(foo).Visible = True Then
  507.                 OtlSet.TopIdx = foo
  508.                 OtlSet.SelectIdx = OtlSet.TopIdx
  509.                 Exit For
  510.             End If
  511.         Next foo
  512.     End If
  513.     OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  514.     
  515. Case KEY_DOWN
  516.     If OtlSet.CurrentLine < OtlSet.DisplayCount Then
  517.         OtlSet.CurrentLine = OtlSet.CurrentLine + 1
  518.         OtlSet.SelectIdx = OtlSet.DisplayIdx(OtlSet.CurrentLine)
  519.     Else
  520.         For foo = OtlSet.DisplayIdx(OtlSet.CurrentLine) + 1 To Otldat.Count
  521.             If Otldat(foo).Visible = True Then
  522.                 OtlSet.TopIdx = OtlSet.DisplayIdx(2)
  523.                 OtlSet.SelectIdx = foo
  524.                 Exit For
  525.             End If
  526.         Next foo
  527.     End If
  528.     OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  529.  
  530. Case Else
  531. End Select
  532. End Sub
  533.  
  534. 'Processes MouseDown to get coordinates of click.
  535.  
  536. Sub OutlineMouseDown2Line(OtlSet As OtlSetup, Otldat As CollectionEx, y As Single, x As Single)
  537. On Error Resume Next
  538. OtlSet.CurrentLine = (y \ OtlSet.LineHeight) + 1
  539. OtlSet.ElementClicked = (x - Otldat(OtlSet.DisplayIdx(OtlSet.CurrentLine)).Level * OtlSet.ColWidth) \ OtlSet.ColWidth  '0=+/-, 1=Pic, 2=Caption
  540. If OtlSet.ElementClicked > 2 Then OtlSet.ElementClicked = 2
  541.  
  542. If OtlSet.LineFlag = 0 And OtlSet.ElementClicked = 0 Then
  543.   OtlSet.ElementClicked = 1
  544. ElseIf OtlSet.LineFlag = 0 And OtlSet.ElementClicked = 1 Then
  545.   OtlSet.ElementClicked = 2
  546. End If
  547. If OtlSet.BmpFlag = 0 And OtlSet.ElementClicked = 1 Then OtlSet.ElementClicked = 2
  548. End Sub
  549.  
  550.  
  551. 'Setup routine for plus/minus
  552.  
  553. Sub OutlinePlusMinusSetup(PlusPic As Control, PlusFile As String, MinusPic As Control, MinusFile As String)
  554. On Error Resume Next
  555.  
  556. Set gPlusPic = PlusPic
  557. Set gMinusPic = MinusPic
  558.  
  559. If PlusFile > "" Then gPlusPic.Picture = LoadPicture(PlusFile)
  560. If MinusFile > "" Then gMinusPic.Picture = LoadPicture(MinusFile)
  561.  
  562. End Sub
  563.  
  564. 'This is main drawing routine for outline control.
  565.  
  566. Sub OutlineRefresh(OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  567.  
  568. 'On Error Resume Next
  569. 'Paints control from data array
  570. Dim foo As Integer, foobar As Integer, TotItems As Long
  571. Dim CurrY As Integer, currX As Integer
  572. Dim BmpWidth As Integer, BmpHeight As Integer
  573. Dim TwipsY As Integer, TwipsX As Integer, TxtWidth As Integer
  574. Dim LineCount As Integer, HoldForeColor As Long
  575. Dim TotVis As Long, SelPnt As Long
  576. ReDim PrevLevelLine(20) As Integer
  577. Dim PrevBmpFile As Picture
  578. Dim SearchLevel As Integer
  579. 'GMG 989818:
  580. Dim yLine1 As Single, yLine2 As Single
  581.  
  582. If ChangingScroll Then
  583.     Exit Sub 'don't recurse scroll change
  584. End If
  585.  
  586. TwipsY = Screen.TwipsPerPixelY
  587. TwipsX = Screen.TwipsPerPixelX
  588. 'OtlSet.LineHeight = 12 * twipsx
  589. BmpWidth = OtlSet.LineHeight
  590. BmpHeight = OtlSet.LineHeight
  591. 'Just changing select bar?
  592. If OtlSet.TopIdx = OtlSet.PrevTop And OtlSet.VisChangeFlag = False Then
  593.     'OtlPic.AutoRedraw = False
  594.     For foo = 1 To OtlSet.DisplayCount
  595.         CurrY = (foo - 1) * OtlSet.LineHeight
  596.         If OtlSet.DisplayIdx(foo) = OtlSet.SelectIdx Then
  597.             OtlPic.CurrentY = CurrY
  598.             currX = OutlineSetX(3, Otldat(OtlSet.DisplayIdx(foo)).Level, OtlSet)
  599.             TxtWidth = currX + OtlPic.TextWidth(Otldat(OtlSet.DisplayIdx(foo)).Caption) + 75
  600.             OtlPic.Line (currX + 10, CurrY)-(TxtWidth, CurrY + OtlSet.LineHeight - TwipsY), OtlSet.SelectColor, BF
  601.             OtlSet.CurrentLine = foo
  602.             'Print Caption
  603.             OtlPic.CurrentY = CurrY
  604.             OtlPic.CurrentX = currX
  605.             HoldForeColor = OtlPic.ForeColor
  606.             OtlPic.ForeColor = OtlSet.SelectTextColor
  607.             OtlPic.Print " " & Otldat(OtlSet.DisplayIdx(foo)).Caption
  608.             OtlPic.ForeColor = HoldForeColor
  609.         Else
  610.             If OtlSet.DisplayIdx(foo) = OtlSet.PrevSel Then
  611.                 OtlPic.CurrentY = CurrY
  612.                 currX = OutlineSetX(3, Otldat(OtlSet.DisplayIdx(foo)).Level, OtlSet)
  613.                 TxtWidth = currX + OtlPic.TextWidth(Otldat(OtlSet.DisplayIdx(foo)).Caption) + 75
  614.                 OtlPic.Line (currX + 10, CurrY)-(TxtWidth, CurrY + OtlSet.LineHeight - TwipsY), OtlPic.BackColor, BF
  615.                 'Print Caption
  616.                 OtlPic.CurrentY = CurrY
  617.                 OtlPic.CurrentX = currX
  618.                 OtlPic.Print " " & Otldat(OtlSet.DisplayIdx(foo)).Caption
  619.             End If
  620.         End If
  621.     Next foo
  622.     'OtlPic.AutoRedraw = True
  623. Else
  624.     Erase OtlSet.DisplayIdx
  625.     OtlPic.Cls
  626.     'TotItems = UBound(OtlDat)
  627.     TotItems = Otldat.Count
  628.     LineCount = 0
  629.     For foo = OtlSet.TopIdx To TotItems
  630.         If Otldat(foo).Visible = True Then
  631.             CurrY = (LineCount) * OtlSet.LineHeight
  632.             If LineCount = 0 Then
  633.                 OtlSet.TopIdx = foo
  634.             End If
  635.             OtlSet.DisplayIdx(LineCount + 1) = foo
  636.             'Print Select Highlight
  637.             If OtlSet.SelectIdx = foo Then
  638.                 OtlPic.CurrentY = CurrY
  639.                 currX = OutlineSetX(3, Otldat(foo).Level, OtlSet)
  640.                 TxtWidth = currX + OtlPic.TextWidth(Otldat(foo).Caption) + 75
  641.                 OtlPic.Line (currX + 10, CurrY)-(TxtWidth, CurrY + OtlSet.LineHeight - TwipsY), OtlSet.SelectColor, BF
  642.                 OtlSet.CurrentLine = LineCount + 1
  643.                 HoldForeColor = OtlPic.ForeColor
  644.                 
  645.                 'Print Select Caption
  646.                 OtlPic.ForeColor = OtlSet.SelectTextColor
  647.                 OtlPic.CurrentY = CurrY
  648.                 OtlPic.CurrentX = currX
  649.                 OtlPic.Print " " & Otldat(foo).Caption
  650.                 OtlPic.ForeColor = HoldForeColor
  651.             Else
  652.                 'Print Caption
  653.                 OtlPic.CurrentY = CurrY
  654.                 currX = OutlineSetX(3, Otldat(foo).Level, OtlSet)
  655.                 OtlPic.CurrentX = currX
  656.                 OtlPic.Print " " & Otldat(foo).Caption
  657.             End If
  658.             'blt bmp
  659.             If OtlSet.BmpFlag = 1 Then
  660.                 OtlPic.CurrentY = CurrY
  661.                 currX = OutlineSetX(2, Otldat(foo).Level, OtlSet)
  662.                 OtlPic.CurrentX = currX
  663.                 
  664.                 'do bitmap by kind
  665.                 'If OtlDat(foo).Level = OtlSet.Levels - 1 Then
  666.                 If Not Otldat(foo).IsParent Then
  667.                     'Leaf
  668.                     
  669.                     If Not Otldat(foo).Bitmap Is Nothing Then
  670.                         Err = 0
  671.                         If PrevBmpFile <> Otldat(foo).Bitmap Then
  672.                             'gCustomPic.Picture = LoadPicture(OtlDat(foo).Bitmap)
  673.                             Set gCustomPic.Picture = Otldat(foo).Bitmap
  674.                             If Err <> 0 Then
  675.                                 Err = 0
  676.                                 'gCustomPic.Picture = LoadPicture(App.Path & "\" & OtlDat(foo).Bitmap)
  677.                                 Set gCustomPic.Picture = Otldat(foo).Bitmap
  678.                             End If
  679.                             If Err = 0 Then
  680.                                 Set PrevBmpFile = Otldat(foo).Bitmap
  681.                             End If
  682.                         End If
  683.                         If Err = 0 And OtlSet.CheckmarkFlag = 0 Then
  684.                             OtlPic.PaintPicture gCustomPic.Picture, currX, CurrY
  685.                         Else
  686.                             If OtlSet.CheckmarkFlag And (Otldat(foo).Selected = 1) Then
  687.                               OtlPic.PaintPicture gLeafCheckedPic.Picture, currX, CurrY
  688.                             Else
  689.                               OtlPic.PaintPicture gLeafPic.Picture, currX, CurrY
  690.                             End If
  691.                         End If
  692.                     Else
  693.                         If OtlSet.CheckmarkFlag And (Otldat(foo).Selected = 1) Then
  694.                           OtlPic.PaintPicture gLeafCheckedPic.Picture, currX, CurrY
  695.                         Else
  696.                           OtlPic.PaintPicture gLeafPic.Picture, currX, CurrY
  697.                         End If
  698.                     End If
  699.                 Else
  700.                     PaintBranchBmp OtlPic, Otldat(foo).Expanded, Otldat(foo).Selected, OtlSet.CheckmarkFlag, currX, CurrY, OtlSet
  701.                 End If
  702.             End If
  703.             'draw lines with default forecolor
  704.             'MOD FOR EXPLORER STYLE DOTTED LINES...
  705.             If OtlSet.LineFlag = 1 Then
  706.                 PrevLevelLine(Otldat(foo).Level + 1) = LineCount
  707.                 currX = OutlineSetX(0, Otldat(foo).Level, OtlSet)
  708.                 'horizontal lines connecting subitems
  709.                 DotLine95 OtlPic, currX, CurrY + OtlSet.LineHeight \ 2, currX + OtlSet.ColWidth * 0.6, CurrY + OtlSet.LineHeight \ 2
  710.                 If LineCount = 0 Then
  711.                     If Otldat(foo).Level > 0 Then DotLine95 OtlPic, currX, CurrY + OtlSet.LineHeight \ 2, currX, CurrY
  712.                 Else
  713.                     If Otldat(foo - 1).Level = Otldat(foo).Level Then
  714.                         'vertical lines connecting subitems
  715.                         DotLine95 OtlPic, currX, CurrY + OtlSet.LineHeight \ 2, currX, CurrY - OtlSet.LineHeight \ 2 '- twipsy
  716.                     Else
  717.                         If Otldat(foo - 1).Level < Otldat(foo).Level Then
  718.                             'vertical line below pictures/folders
  719.                             DotLine95 OtlPic, currX, CurrY + OtlSet.LineHeight \ 2, currX, CurrY
  720.                         Else
  721.                             For foobar = LineCount - 1 To 1 Step -1
  722.                                 If Otldat(OtlSet.DisplayIdx(foobar) + 1).Level <= Otldat(foo).Level Then
  723.                                     Exit For
  724.                                 End If
  725.                             Next foobar
  726.                             If Otldat(OtlSet.DisplayIdx(foobar) + 1).Level <= Otldat(foo).Level Then
  727.                                 'vertical line between collapsed parents
  728.                                 DotLine95 OtlPic, currX, CurrY + OtlSet.LineHeight \ 2, currX, OtlSet.LineHeight * (foobar + 1) - OtlSet.LineHeight \ 2
  729.                             Else
  730.                                 'Equal level at top or next/any is above limit of control visible area
  731.                                 DotLine95 OtlPic, currX, CurrY + OtlSet.LineHeight \ 2, currX, 0 'OtlSet.LineHeight * (foobar + 1) - OtlSet.LineHeight \ 2
  732.                             End If
  733.                         End If
  734.                     End If
  735.                 End If
  736.             End If
  737.             
  738.             'set next line
  739.             LineCount = LineCount + 1
  740.             If LineCount >= OtlSet.DisplayLines Or foo = Otldat.Count Then
  741.                 Exit For
  742.             End If
  743.         End If
  744.     Next foo
  745.     LineCount = LineCount - 1
  746.     OtlSet.DisplayCount = LineCount + 1
  747.     
  748.     'Complete Line processing
  749.     If OtlSet.LineFlag = 1 And foo < TotItems Then
  750.         SearchLevel = Otldat(foo).Level  'Last item displayed
  751.         For foobar = foo + 1 To TotItems
  752.             If Otldat(foobar).Level <= SearchLevel Then
  753.                 currX = OutlineSetX(0, Otldat(foobar).Level, OtlSet)
  754.                 'vertical line down from expanded parent
  755.                 DotLine95 OtlPic, currX, OtlPic.Height, currX, PrevLevelLine(Otldat(foobar).Level + 1) * OtlSet.LineHeight '- twipsy
  756.                 SearchLevel = Otldat(foobar).Level - 1
  757.                 If SearchLevel < 0 Then Exit For
  758.             End If
  759.         Next foobar
  760.     End If
  761.     
  762.     'draw plus minus boxes
  763.     LineCount = 0
  764.     CurrY = 0
  765.     If (OtlSet.PlusFlag = 1) Then
  766.       For foo = OtlSet.TopIdx To TotItems
  767.         'If (OtlDat(foo).Level < OtlSet.Levels - 1) And OtlDat(foo).Visible Then
  768.         If (Otldat(foo).IsParent) And Otldat(foo).Visible Then
  769.             CurrY = (LineCount) * OtlSet.LineHeight + OtlSet.LineHeight / 2 - Screen.TwipsPerPixelY
  770.             currX = OutlineSetX(1, Otldat(foo).Level, OtlSet)
  771.             OtlPic.CurrentX = currX
  772.             'does the branch have child entries?
  773.             If foo = TotItems Then
  774.                 'last entry so no children
  775.                 Drawbox Pic:=OtlPic, x:=(currX), y:=(CurrY), Plus:=False
  776.             Else
  777.                 'no kids
  778.                 If Otldat(foo + 1).Level <= Otldat(foo).Level Then
  779.                     Drawbox Pic:=OtlPic, x:=(currX), y:=(CurrY), Plus:=False
  780.                     Else
  781.                     'does have children, but is it expanded already?
  782.                     If Otldat(foo).Expanded = True Then
  783.                         Drawbox Pic:=OtlPic, x:=(currX), y:=(CurrY), Plus:=False
  784.                     Else 'PLUS - has unexpanded children
  785.                         Drawbox Pic:=OtlPic, x:=(currX), y:=(CurrY), Plus:=True
  786.                     End If
  787.                 End If
  788.             End If
  789.         End If
  790.         If Otldat(foo).Visible Then
  791.             'set next line
  792.             LineCount = LineCount + 1
  793.             If LineCount >= OtlSet.DisplayLines Or foo = Otldat.Count Then
  794.                 Exit For
  795.             End If
  796.         End If
  797.       Next foo
  798.     End If
  799.     'Set Scroll Bar
  800.     'Determine visible items
  801.     If OtlSet.VisChangeFlag Then
  802.         ChangingScroll = True
  803.         OtlSet.VisChangeFlag = False
  804.         OtlSet.VisibleItems = -1
  805.         For foo = 1 To TotItems
  806.             If Otldat(foo).Visible = True Then
  807.                 OtlSet.VisibleItems = OtlSet.VisibleItems + 1
  808.                 Otldat(foo).VisibleIdx = OtlSet.VisibleItems
  809.             Else
  810.                 Otldat(foo).VisibleIdx = -1
  811.             End If
  812.         Next foo
  813.         If OtlSet.VisibleItems > 0 Then
  814.             OtlScroll.Visible = True
  815.             OtlScroll.Max = OtlSet.VisibleItems
  816.         Else
  817.             OtlScroll.Visible = False
  818.             OtlScroll.value = 0
  819.         End If
  820.         OtlScroll.SmallChange = 1
  821.         OtlScroll.LargeChange = 10
  822.         ChangingScroll = False
  823.     End If
  824. End If
  825. If OtlScroll.Visible = True Then
  826.     ChangingScroll = True
  827.     OtlScroll.value = Otldat(OtlSet.SelectIdx).VisibleIdx
  828.     ChangingScroll = False
  829. End If
  830. OtlSet.PrevSel = OtlSet.SelectIdx
  831. OtlSet.PrevTop = OtlSet.TopIdx
  832.  
  833. End Sub
  834. Public Sub PaintBranchBmp(OtlPic As Object, Expanded As Integer, Selected As Integer, CheckmarkFlag As Integer, currX As Integer, CurrY As Integer, OtlSet As OtlSetup)
  835.  
  836. If CheckmarkFlag = False Then
  837.   If Expanded Then
  838.     OtlPic.PaintPicture gBranchOpenPic.Picture, currX, CurrY
  839.   Else
  840.     OtlPic.PaintPicture gBranchClosedPic.Picture, currX, CurrY
  841.   End If
  842. Else
  843.   If Expanded Then
  844.     Select Case Selected
  845.     Case 0
  846.       OtlPic.PaintPicture gBranchOpenPic.Picture, currX, CurrY
  847.     Case 1
  848.       OtlPic.PaintPicture gBranchOpenAllPic.Picture, currX, CurrY
  849.     Case 2
  850.       OtlPic.PaintPicture gBranchOpenSomePic.Picture, currX, CurrY
  851.     End Select
  852.   Else
  853.     Select Case Selected
  854.     Case 0
  855.       OtlPic.PaintPicture gBranchClosedPic.Picture, currX, CurrY
  856.     Case 1
  857.       OtlPic.PaintPicture gBranchClosedAllPic.Picture, currX, CurrY
  858.     Case 2
  859.       OtlPic.PaintPicture gBranchClosedSomePic.Picture, currX, CurrY
  860.     End Select
  861.   End If
  862. End If
  863.  
  864. End Sub
  865.                         
  866.                        
  867.  
  868. Public Function OutlineSetX(ViewType As Integer, Level As Integer, OtlSet As OtlSetup) As Integer
  869. 'used for win95 style outlines -- always have bmp, lines, +/-
  870. 'ViewType --> 0 = line, 1 = +/- box, 2 = bmp, 3 = text
  871. Dim currX As Integer
  872.  
  873. 'added to move text over if bitmaps or lines are not displayed
  874. If OtlSet.BmpFlag = 0 And ViewType = 3 Then ViewType = 2
  875. If OtlSet.PlusFlag = 0 And OtlSet.BmpFlag = 0 And ViewType = 3 Then ViewType = 2
  876. If OtlSet.PlusFlag = 0 And OtlSet.BmpFlag = 0 And OtlSet.LineFlag = 0 And ViewType = 2 Then ViewType = 1
  877. If OtlSet.PlusFlag = 0 And OtlSet.BmpFlag = 1 And OtlSet.LineFlag = 0 And ViewType = 2 Then ViewType = 1
  878. If OtlSet.PlusFlag = 0 And OtlSet.BmpFlag = 1 And OtlSet.LineFlag = 0 And ViewType = 3 Then ViewType = 2
  879.  
  880.  
  881. OtlSet.ColWidth = 17 * Screen.TwipsPerPixelX
  882. Select Case ViewType
  883. Case 0 'lines
  884.   If Level > 0 Then
  885.     currX = Level * OtlSet.ColWidth + OtlSet.LineHeight \ 2
  886.   Else
  887.     currX = OtlSet.LineHeight \ 2
  888.   End If
  889. Case 1 '+/- box
  890.   If Level > 0 Then
  891.     currX = Level * OtlSet.ColWidth + OtlSet.LineHeight \ 2
  892.   Else
  893.     currX = OtlSet.LineHeight \ 2 + Screen.TwipsPerPixelX
  894.   End If
  895. Case 2 'bmp
  896.   If Level > 0 Then
  897.     currX = Level * OtlSet.ColWidth + OtlSet.ColWidth + Screen.TwipsPerPixelX * 2
  898.   Else
  899.     currX = OtlSet.ColWidth + (Screen.TwipsPerPixelX * 2)
  900.   End If
  901. Case 3 'text caption
  902.   If Level > 0 Then
  903.     currX = Level * OtlSet.ColWidth + OtlSet.ColWidth + OtlSet.LineHeight + (Screen.TwipsPerPixelX * 2)
  904.   Else
  905.     currX = OtlSet.ColWidth + OtlSet.LineHeight + (Screen.TwipsPerPixelX * 2)
  906.   End If
  907. End Select
  908. OutlineSetX = currX
  909. End Function
  910.  
  911. Sub Drawbox(Pic As Object, x As Long, y As Long, Plus As Integer)
  912. Dim twips As Integer, Holdstyle As Integer
  913. twips = Screen.TwipsPerPixelY
  914. Holdstyle = Pic.DrawStyle
  915.  
  916. Pic.Line (x - 4 * twips, y - 4 * twips)-Step(8 * twips, 8 * twips), &HFFFFFF, BF
  917. Pic.DrawStyle = 0
  918. Pic.Line (x - 4 * twips, y - 4 * twips)-Step(8 * twips, 8 * twips), &H808080, B
  919. Pic.Line (x - 2 * twips, y)-Step(5 * twips, 0), &H0
  920. If Plus Then Pic.Line (x, y - 2 * twips)-Step(0, 5 * twips), &H0
  921. Pic.DrawStyle = Holdstyle
  922.  
  923. End Sub
  924.  
  925.  
  926.  
  927. Public Sub DotLine95(OtlPic As Control, x1, y1, x2, y2)
  928. 'draws horizontal or vertical only ... no angles in this rev
  929. Dim foo As Integer, LowVal, HighVal, TwipsX As Integer, TwipsY As Integer
  930. Dim OtlPicHdc As Long
  931. Dim Checkit As Long
  932. TwipsX = Screen.TwipsPerPixelX
  933. TwipsY = Screen.TwipsPerPixelY
  934. OtlPicHdc = OtlPic.hDC
  935. If x1 = x2 Then
  936.   If y1 < y2 Then
  937.     LowVal = y1
  938.     HighVal = y2
  939.   Else
  940.     LowVal = y2
  941.     HighVal = y1
  942.   End If
  943.   If (LowVal \ TwipsY) Mod 2 = 1 Then LowVal = (LowVal \ TwipsY) * TwipsY - TwipsY
  944.   If (x1 \ TwipsX) Mod 2 = 1 Then x1 = (x1 \ TwipsX) * TwipsX + TwipsX
  945.   For foo = LowVal To HighVal Step TwipsX * 2
  946.     Checkit = SetPixel(OtlPicHdc, x1 / TwipsX, foo / TwipsY, &H808080)
  947.   Next foo
  948. Else
  949.   If x1 < x2 Then
  950.     LowVal = x1
  951.     HighVal = x2
  952.   Else
  953.     LowVal = x2
  954.     HighVal = x1
  955.   End If
  956.   If (LowVal \ TwipsX) Mod 2 = 1 Then
  957.     LowVal = (LowVal \ TwipsX) * TwipsX + TwipsX
  958.     HighVal = (HighVal \ TwipsX) * TwipsX + TwipsX
  959.   End If
  960.   If (HighVal \ TwipsX) Mod 2 = 1 Then HighVal = (HighVal \ TwipsX) * TwipsX + TwipsX
  961.   If (y1 \ TwipsY) Mod 2 = 1 Then y1 = (y1 \ TwipsY) * TwipsY - TwipsY
  962.   For foo = LowVal To HighVal Step TwipsY * 2
  963.     Checkit = SetPixel(OtlPicHdc, foo / TwipsX, y1 / TwipsY, &H808080)
  964.   Next foo
  965. End If
  966. End Sub
  967.  
  968.  
  969. 'Used to adjust outline control in response to scroll bar changes.
  970.  
  971. Sub OutlineScroll(ScrollValue As Integer, OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, Otldat As CollectionEx)
  972. Dim foo As Integer, Vispoint As Long
  973. If ChangingScroll Then Exit Sub
  974. Vispoint = -1
  975. If ScrollValue < Otldat(OtlSet.DisplayIdx(1)).VisibleIdx Then
  976.     For foo = OtlSet.DisplayIdx(1) To 1 Step -1
  977.         If ScrollValue = Otldat(foo).VisibleIdx Then
  978.             OtlSet.CurrentLine = 1
  979.             OtlSet.SelectIdx = foo
  980.             OtlSet.TopIdx = OtlSet.SelectIdx
  981.             OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  982.             Exit For
  983.         End If
  984.     Next foo
  985. Else
  986.     If ScrollValue > Otldat(OtlSet.DisplayIdx(OtlSet.DisplayCount)).VisibleIdx Then
  987.         'find bottom to select
  988.         For foo = OtlSet.DisplayIdx(OtlSet.DisplayCount) To Otldat.Count
  989.             If ScrollValue = Otldat(foo).VisibleIdx Then
  990.                 OtlSet.CurrentLine = OtlSet.DisplayCount
  991.                 OtlSet.SelectIdx = foo
  992.                 Exit For
  993.             End If
  994.         Next foo
  995.         'Find TopIdx for display
  996.         For foo = OtlSet.SelectIdx To 1 Step -1
  997.             If Otldat(foo).VisibleIdx = ScrollValue - OtlSet.DisplayCount Then Exit For
  998.         Next foo
  999.         OtlSet.TopIdx = foo + 1
  1000.         OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  1001.     Else
  1002.         'make sure current item is selected within display when scrollbar moves
  1003.         For foo = 1 To OtlSet.DisplayCount
  1004.             If Otldat(OtlSet.DisplayIdx(foo)).VisibleIdx = ScrollValue Then
  1005.                 OtlSet.CurrentLine = foo
  1006.                 OtlSet.SelectIdx = OtlSet.DisplayIdx(foo)
  1007.                 OutlineRefresh OtlPic, OtlScroll, OtlSet, Otldat
  1008.             End If
  1009.         Next foo
  1010.     End If
  1011. End If
  1012. OtlPic.SetFocus
  1013. End Sub
  1014.  
  1015. 'Initializes the parameters for a code-based outline control
  1016.  
  1017. Sub OutlineSetup(OtlPic As Control, OtlScroll As Control, OtlSet As OtlSetup, DataFields As String, Bmps As Boolean, Lines As Boolean, Plus As Boolean, Checkmarks As Boolean, SelectColor As Long, SelectTextColor As Long, BmpField As String, CheckmarkField As String)
  1018. 'Initializes the OtlSetup control psuedo-properties
  1019. 'Note: if using bitmaps for bullets, must have pic loaded for branch open, closed, and leaf
  1020. Dim foo As Integer
  1021. 'Dim VarArr() As String
  1022. 'ReDim VarArr(0) As String
  1023.  
  1024. 'OtlScroll.Move OtlPic.ScaleWidth - OtlScroll.Width, 0, OtlScroll.Width, OtlPic.ScaleHeight
  1025. OtlScroll.Move OtlPic.Width - OtlScroll.Width, 0, OtlScroll.Width, OtlPic.Height
  1026.  
  1027. 'removed for test - kdq
  1028. 'foo = Parse2Array(DataFields, VarArr(), ",")
  1029. 'DoEvents
  1030. 'OtlSet.Levels = UBound(VarArr) + 1
  1031.  
  1032. 'Erase OtlSet.VariableNames()
  1033. 'For foo = 0 To OtlSet.Levels - 1
  1034. '    OtlSet.VariableNames(foo) = Trim$(VarArr(foo))
  1035. 'Next foo
  1036.  
  1037. If BmpField > "" Then OtlSet.BmpField = BmpField Else OtlSet.BmpField = ""
  1038. OtlSet.VisChangeFlag = True 'force first count
  1039. If Bmps Then OtlSet.BmpFlag = 1 Else OtlSet.BmpFlag = 0
  1040. If Lines Then OtlSet.LineFlag = 1 Else OtlSet.LineFlag = 0
  1041. If Plus Then OtlSet.PlusFlag = 1 Else OtlSet.PlusFlag = 0
  1042. If Checkmarks Then OtlSet.CheckmarkFlag = True Else OtlSet.CheckmarkFlag = False
  1043. OtlSet.CheckmarkField = CheckmarkField
  1044. OtlSet.LineHeight = OtlPic.TextHeight("X") '* 1.1
  1045.  
  1046. 'If OtlSet.LineHeight Mod Screen.TwipsPerPixelY <> 0 Then OtlSet.LineHeight = (OtlSet.LineHeight \ Screen.TwipsPerPixelY) * Screen.TwipsPerPixelY + Screen.TwipsPerPixelY
  1047. OtlSet.LineHeight = OtlSet.LineHeight + ((OtlSet.LineHeight \ Screen.TwipsPerPixelY) Mod 4) * Screen.TwipsPerPixelY
  1048.  
  1049. OtlSet.DisplayLines = OtlPic.Height \ OtlSet.LineHeight
  1050. Erase OtlSet.DisplayIdx
  1051. OtlSet.SelectColor = SelectColor
  1052. OtlSet.SelectTextColor = SelectTextColor
  1053. OtlSet.TopIdx = 1
  1054. OtlSet.SelectIdx = 1
  1055. OtlSet.PrevTop = -1
  1056. OtlSet.PrevSel = -1
  1057.  
  1058. End Sub
  1059.  
  1060. 'Stretches a picture to a region in Destination
  1061.  
  1062. Sub StrBltAllToPoint(dest As Object, dX As Integer, dY As Integer, dWidth As Integer, dHeight As Integer, source As Control)
  1063. Dim foo As Integer, DestHoldMode As Integer, SrcHoldMode As Integer
  1064.  
  1065. DestHoldMode = dest.ScaleMode
  1066. dest.ScaleMode = 3 'Pixels
  1067. SrcHoldMode = source.ScaleMode
  1068. source.ScaleMode = 3 'Pixels
  1069.  
  1070. foo = StretchBlt(dest.hDC, dX, dY, dWidth, dHeight, source.hDC, 0, 0, source.ScaleWidth, source.ScaleHeight, &HCC0020)
  1071.  
  1072. dest.ScaleMode = DestHoldMode
  1073. source.ScaleMode = SrcHoldMode
  1074.  
  1075. End Sub
  1076.  
  1077.