home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / fld2_16 / folders2.bas < prev   
Encoding:
BASIC Source File  |  1994-12-31  |  51.4 KB  |  1,345 lines

  1. ' FOLDERS-II v1.6 by Antonio Cordero. Original module by James Parr.
  2.  
  3. ' This module is Public Domain
  4.  
  5. ' This module allows you to use Folders without the need of a VBX control.
  6. ' The differences of version 1.0 with the original module by James Parr are
  7. ' the following:
  8. '  - 3D
  9. '  - More than a folder per form
  10. '  - Can use panels at the same time as folders
  11. '  - The Tabs text don't overwrite if too large
  12. '  - If more than a Tab row, the folder will adjust its position to see all of them
  13. '  - You can enable/disable each Tab
  14. '  - Accelerators to change the current Tab
  15.  
  16. ' Version 1.5:
  17. '  - Better support of form colors, no more necessary to be bright gray
  18. '  - FolderEnable, FolderDisable, FolderEnabled()
  19. '  - Can put a graphic in each Tab in every position: Left, Right, Top, Bottom
  20. '  - Better use of panel's area. Only the Caption is overwritten
  21. '  - Support for Folders inside Folders
  22. '  - Tab styles: Normal (Chamfered), Slanted, Chicago
  23. '  - Can specify offset between rows
  24. '  - Name changes:
  25. '      CurrentFolder() become CurrentTab()
  26. '      NumFolders()    become NumTabs()
  27. '  - Can share controls over all the Tabs of a Folder using SetFixedControl
  28. '  - TightenForm modified: don't change vertical position and allows space below
  29. '  - Multiple lines titles
  30. '  - Can know which Tab has been clicked before and after the change
  31.  
  32. ' Version 1.6:
  33. '  - First international version. Being released to the Internet
  34. '  - Changes and corrections to comments when traducing to English
  35. '  - Disabled graphics are a lot faster
  36. '  - New effect: 3D border selectable at left/right side of folder
  37. '  - New functions: FolderLeft, FolderTop, FolderWidth, FolderHeight
  38. '  - New sub: FolderMove
  39. '  - Bug with colors in folder with more than one row if inside a container
  40. '  - Corrected some other drawing bugs (too many)
  41. '  - New sub: ReDefineFolder
  42. '  - Can change number of tabs at runtime
  43. '  - New effect: overlapped or separated tabs
  44. '  - Colored Tabs (Compatibility WARNING: see FloodColor/ForeColor prop. below)
  45. '  - Changed: folders inside folders need to be inside a picturebox
  46. '             (problem with SSPanels not having ScaleMode property)
  47. '  - Can redefine X offset of Tabs diagonals in the Style parameter
  48.  
  49. ' For any sugerence or bug i can be reached at:
  50. '  - Internet E-mail: ccanto@eui.upm.es
  51. '  - "Las Profundidades del DEMo╤O" or ...uh..."The Deepnesses of the DEM'N" :-)
  52. '      +34(Spain)-1(Madrid)-7300942 (put message to cosysop NetDevil)
  53.  
  54. ' Form of use:
  55. ' ------------
  56. ' Create as much SSPanels (THREED.VBX) as tabs you want in the folder, all in a control array.
  57. ' If you want to use multiple lines captions, use "\$" as line separator.
  58. ' Put the following properties to the SSPanels:
  59. '   Caption        = the Tab title
  60. '   Alignment      = 0 - (Left Justify) - TOP
  61. '   BevelInner     = 0 - none
  62. '   BevelOuter     = 2 - raised
  63. '   BevelWidth     = 2
  64. '   BorderWidth    = 2
  65. '   Outline        = True
  66. '   RoundedCorners = False
  67. '   Tag            = folder identification, maybe the panels name
  68. '   BackColor      = as you like
  69. '   FloodColor     = background color for the tab
  70. '      (use the same as BackColor to be compatible with previous versions)
  71. '   ForeColor      = foreground color for the tab
  72. '
  73. ' Create two PictureBoxes that you will pass as parameters to DefineFolders. No
  74. '  properties needed.
  75. '
  76. ' If you want to use graphics in the tabs, create a control array of PictureBoxes that
  77. '  contain the graphics and with the Tag property the same as of the panels. If any of
  78. '  the PictureBoxes have no graphic (Picture=(none)) the corresponding tab will have
  79. '  no graphic. But you must make an array of N pictureboxes being N the number of
  80. '  panels.
  81.  
  82. ' Put in Form1.Load:
  83. '  Success% = DefineFolders (Index, NumTabsPerRow, Panel3D(0), FoldersTag,
  84. '                            TabPicture1, TabPicture2, Container, TabStyle,
  85. '                            RowOffset, PicturesPosition, GrayPictures,
  86. '                            LeftBorder, BetweenTabs)
  87. ' The parameters are:
  88. '  Index : index of the folder in the program, 0 to 49
  89. '  NumTabsPerRow : number of Tabs per row :). 0 means all in one row.
  90. '  Panel3D(0) : first element of an array of 3D panels created as said above.
  91. '               Index 0 panel will be the base for the others.
  92. '  FoldersTag : tag common to all the panels of the folder. Allows you to have
  93. '               other SSPanels in the same form assuming that they don't have
  94. '               this tag. It also allows you to put more than one folder in
  95. '               the form.
  96. '  TabPicture1 y TabPicture2 : the pictures created as said above.
  97. '  Container : keyword Nothing if the folder is directly in a Form, or, the
  98. '              container control. The container control must have the ScaleMode
  99. '              property, so the best choice is a PictureBox.
  100. '  TabStyle : low byte: 0 = Chamfered, 1 = Slanted, 2 = Chicago
  101. '             high byte: X offset of Tabs diagonals (0=default) (pixels)
  102. '                        (only for Chamfered and Slanted, i.e. &H0601 = Slanted
  103. '                         with diagonal.X = 6)
  104. '  RowOffset : horizontal offset between rows (pixels).
  105. '  PicturesPosition : graphics position: 0 = Left, 1 = Right, 2 = Top, 3 = Bottom
  106. '  GrayPictures : True if the graphics must be grayed when disabled.
  107. '  LeftBorder : True if the 3D border of not-first rows is at the left side.
  108. '  BetweenTabs : number of pixels between tabs. Can be negative to make
  109. '                overlapped tabs (pixels).
  110.  
  111. ' If you want to use accelerators to access a tab, make form1.KeyPreview = TRUE
  112. ' and put in form1.KeyUp:
  113. '  keycode = GotoFolderByAccel(Index, keycode, shift)
  114. ' Being Index the folder index in the program
  115. '
  116. ' WARNING: If you click the keys to access a tab and that tab is the current,
  117. '          the control who have the focus could be activated (clicked).
  118. '          The solution is to make the TabStop property to False in all the
  119. '          controls of the folder.
  120.  
  121. ' Put in TabPicture1.MouseUp:
  122. '  FolderClick Index, Button, X, Y
  123. ' or:
  124. '  i = FolderClickFn (Index, Button, X, Y)
  125. ' Being Index the index to the folder (0-49).
  126. ' The function FolderClickFn returns the selected tab (0 is first)
  127. ' Your can use the function FolderClicked(Index, X, Y) before FolderClick or
  128. '  FolderClickFn to know which tab will be selected before it changes.
  129.  
  130. ' If you want to use shared controls, create them in the first panel (index 0)
  131. '  and, in Form1.Load, after the DefineFolders command:
  132. '    SetFixedControl Index, Control
  133. '  for each shared control (if a control is inside a container, only use
  134. '  SetFixedControl with the container), being Index the index to the folder
  135. '  in the program. Also put in Form1.Unload:
  136. '    ResetFixedControls Index
  137. ' Controls of types Label, Shape, Line, Image, and others without hWnd property
  138. '  cannot be shared, but you can share them if you put them inside a container
  139. '  that have a hWnd property, a picturebox, for example.
  140. ' The best method to share controls is to put them inside a PictureBox and then
  141. '  share only this PictureBox.
  142.  
  143. ' You can use the following routines (Index is the index of the folder):
  144. '  n = CurrentTab (Index) : gets the current tab
  145. '  n = NumTabs (Index) : gets the number of tabs in the folder
  146. '  NextFolder Index : displays the next tab
  147. '  PrevFolder Index : displays the previous tab
  148. '  GotoFolder Index, TabNumber : displays the tab TabNumber (first is 0)
  149. '  TightenForm Index, BelowSpace, NoBorders : adjusts the form around the folder
  150. '                                             with BelowSpace below the folder and
  151. '                                             optional visible borders.
  152. '  TabEnable Index, TabNumber  : enables the tab TabNumber
  153. '  TabDisable Index, TabNumber : disables the tab TabNumber
  154. '  flag% = TabEnabled (Index, TabNumber)  : returns TRUE if the tab TabNumber
  155. '                                           is enabled
  156. '  FolderEnable Index  : enables the folder
  157. '  FolderDisable Index : disables the folder
  158. '  flag% = FolderEnabled (Index) : returns TRUE if the folder is enabled
  159. '  l = FolderLeft (Index)
  160. '  t = FolderTop (Index)
  161. '  w = FolderWidth (Index)
  162. '  h = FolderHeight (Index) : get the folder position and size (in pixels)
  163. '  FolderMove Index, Left, Top : move the folder to position (Left, Top) (pixels)
  164. '  Success% = ReDefineFolders (Index, NumTabsPerRow, TabStyle, RowOffset,
  165. '                              PicturesPosition, GrayPictures, LeftBorder,
  166. '                              BetweenTabs)
  167. '          : Change folder settings, parameters are the same as in DefineFolders
  168. '            You can use it after adding or removing panels.
  169.  
  170. Option Explicit
  171.  
  172. ' Max. 50 folders of 20 tabs (change if necessary)
  173. Const MaxFolders = 50 - 1
  174. Const MaxTabs = 20 - 1
  175. Const MaxFixedControls = 10
  176. Const TabOffsetConstant = 4
  177.  
  178. Global CurrentTab(0 To MaxFolders)  As Integer   ' Current active folder
  179. Global NumTabs(0 To MaxFolders)  As Integer  ' Total number of folders
  180. Global TabEnabled(0 To MaxFolders, 0 To MaxTabs) As Integer ' Tab enabled ?
  181. Global FolderEnabled(0 To MaxFolders) As Integer ' Folder enabled ?
  182.  
  183. Dim Folders(0 To MaxFolders, 0 To MaxTabs)   As Control ' Array of the form's folders
  184. Dim FoldersPictures(0 To MaxFolders, 0 To MaxTabs)   As Control ' Array of the form's folders pictures
  185. Dim VisibleTabs(0 To MaxFolders)  As Integer    ' Number of tabs across screen
  186. Dim OneTabHeight(0 To MaxFolders)  As Integer   ' Height of one row of tabs
  187. Dim FolderTabs(0 To MaxFolders)  As Control     ' Picture to paint tabs on
  188. Dim FolderBorder(0 To MaxFolders)  As Control   ' Picture to paint borders
  189. Dim TabWidth(0 To MaxFolders)  As Long          ' Tab width
  190. Dim NumRows(0 To MaxFolders)  As Integer        ' Number of tabs rows
  191. Dim TabOffset(0 To MaxFolders)  As Integer      ' # of pixels for tab's diagonal
  192. Dim TabAccel(0 To MaxFolders, 0 To MaxTabs) As Integer ' Accelerator keys
  193. Dim FolderContainer(0 To MaxFolders) As Control ' Folder containers
  194. Dim PicturesPosition(0 To MaxFolders) As Integer ' Graphics positions
  195. Dim FixedControls(0 To MaxFolders, 1 To MaxFixedControls) As Control ' Fixed controls
  196. Dim NumFixedControls(0 To MaxFolders) As Integer
  197. Dim TabStyle(0 To MaxFolders)  As Integer
  198. Dim GrayPictures(0 To MaxFolders) As Integer
  199. Dim LeftBorder(0 To MaxFolders) As Integer
  200. Dim BetweenTabs(0 To MaxFolders) As Integer
  201. Dim RowOffset(0 To MaxFolders)  As Long ' Offset between rows
  202.  
  203. ' Used for border/menu sizes
  204. Declare Function getsystemmetrics% Lib "User" (ByVal nIndex%)
  205. ' Used to see if menu is used
  206. Declare Function GetMenu Lib "User" (ByVal hWnd%) As Integer
  207. ' Used to fill zones
  208. Declare Function ExtFloodFill Lib "GDI" (ByVal hDC%, ByVal i%, ByVal i%, ByVal W&, ByVal i%) As Integer
  209. Const FLOODFILLBORDER = 0  ' Fill until color encountered.
  210. Const FLOODFILLSURFACE = 1 ' Fill surface until color not encountered.
  211. ' Used to copy the graphics of the tabs
  212. Declare Function bitblt Lib "GDI" (ByVal hDestDC As Integer, ByVal X As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal XSrc As Integer, ByVal YSrc As Integer, ByVal dwRop As Long) As Integer
  213. ' Used to move fixed controls between tabs
  214. Declare Function setparent% Lib "user" (ByVal H%, ByVal H%)
  215. Declare Function getfocus% Lib "user" ()
  216. ' Used to gray a graphic
  217. Declare Function CreateBitmap Lib "GDI" (ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal nPlanes As Integer, ByVal nBitCount As Integer, ByVal lpBits As Any) As Integer
  218. Declare Function CreatePatternBrush Lib "GDI" (ByVal hBitmap As Integer) As Integer
  219. Declare Function SelectObject Lib "GDI" (ByVal hDC As Integer, ByVal hObject As Integer) As Integer
  220. Declare Function DeleteObject Lib "GDI" (ByVal hObject As Integer) As Integer
  221. Declare Function PatBlt Lib "GDI" (ByVal hDC As Integer, ByVal X As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal dwRop As Long) As Integer
  222. ' Used to fill the tabs
  223. Type Coord        ' This is the type structure for the x and y
  224.     X As Integer  ' coordinates for the polygonal region.
  225.     y As Integer
  226. End Type
  227. Declare Function CreatePolygonRgn Lib "gdi" (lpPoints As Any, ByVal nCount As Integer, ByVal nPolyFillMode As Integer) As Integer
  228. Declare Function Polygon Lib "gdi" (ByVal hDC As Integer, lpPoints As Any, ByVal nCount As Integer) As Integer
  229. Declare Function FillRgn Lib "gdi" (ByVal hDC As Integer, ByVal hrgn As Integer, ByVal hbrush As Integer) As Integer
  230. Declare Function CreateSolidBrush Lib "GDI" (ByVal crColor As Long) As Integer
  231.  
  232. ' Locate the folder controls
  233. ' Set the Folders array to point to the folders
  234. ' Modify each folder to match the first folder (index=0)
  235. Function DefineFolders (idx As Integer, numacross As Integer, Fldr As Control, FolderTag As String, foldertabcontrol As Control, folderbordercontrol As Control, Container As Control, Style As Integer, RowOffs As Integer, PicPosition As Integer, GrayGph As Integer, LeftBdr As Integer, BwTabs As Integer) As Integer
  236. Dim i, i2 As Integer
  237. Dim accel As Integer
  238. Dim titulo As String
  239. Dim numlin, num_lineas As Integer
  240. Dim max As Integer
  241. Dim texto As Integer
  242. Dim oldscalemode As Integer
  243.  
  244.   If idx > MaxFolders Then Exit Function
  245.   LeftBorder(idx) = LeftBdr
  246.   BetweenTabs(idx) = BwTabs
  247.   If LeftBdr Then
  248.     RowOffset(idx) = -RowOffs
  249.   Else
  250.     RowOffset(idx) = RowOffs
  251.   End If
  252.   Set FolderContainer(idx) = Container
  253.   For i = 0 To MaxTabs
  254.     Set FoldersPictures(idx, i) = Nothing
  255.   Next
  256.  
  257.   ' Find out how many folders in an array are on the form
  258.   ' Done by checking each control to see if it is a folder
  259.   '   and then checking each folder to see if it has an index
  260.   '   value (part of an array of folders)
  261.   ' Checks if the tag is correct
  262.   NumTabs(idx) = 0
  263.   On Error GoTo NoIndex
  264.   For i = 0 To Fldr.Parent.Controls.Count - 1
  265.     If TypeOf Fldr.Parent.Controls(i) Is SSPanel Then
  266.       If Fldr.Parent.Controls(i).Index < 0 Or Fldr.Parent.Controls(i).Index > MaxTabs Or Fldr.Parent.Controls(i).Tag <> FolderTag Then
  267.     ' Fill Space
  268.       Else
  269.     If Fldr.Parent.Controls(i).Index > NumTabs(idx) Then NumTabs(idx) = Fldr.Parent.Controls(i).Index
  270.       End If
  271.     End If
  272.   Next i
  273.   On Error GoTo 0
  274.   
  275.   ' Fill the Folders array with pointers to the folder
  276.   '   on the form
  277.   ' Done by the same loop as last time, but this time
  278.   '   I assign it to an array
  279.   ' Also assigns graphics
  280.   On Error GoTo NoIndex
  281.   For i = 0 To Fldr.Parent.Controls.Count - 1
  282.     If TypeOf Fldr.Parent.Controls(i) Is SSPanel Then
  283.       If Fldr.Parent.Controls(i).Index < 0 Or Fldr.Parent.Controls(i).Index > MaxTabs Or Fldr.Parent.Controls(i).Tag <> FolderTag Then
  284.     'Fill Space
  285.       Else
  286.     On Error GoTo 0
  287.     Set Folders(idx, Fldr.Parent.Controls(i).Index) = Fldr.Parent.Controls(i)
  288.     On Error GoTo NoIndex
  289.       End If
  290.     ElseIf TypeOf Fldr.Parent.Controls(i) Is PictureBox Then
  291.     If Fldr.Parent.Controls(i).Index < 0 Or Fldr.Parent.Controls(i).Index > MaxTabs Or Fldr.Parent.Controls(i).Tag <> FolderTag Then
  292.     'Fill Space
  293.     Else
  294.     On Error GoTo 0
  295.     Set FoldersPictures(idx, Fldr.Parent.Controls(i).Index) = Fldr.Parent.Controls(i)
  296.     FoldersPictures(idx, Fldr.Parent.Controls(i).Index).Visible = False
  297.     FoldersPictures(idx, Fldr.Parent.Controls(i).Index).AutoRedraw = True
  298.     FoldersPictures(idx, Fldr.Parent.Controls(i).Index).ScaleMode = 3 ' Pixels
  299.     On Error GoTo NoIndex
  300.     End If
  301.     End If
  302.   Next i
  303.   On Error GoTo 0
  304.   
  305.   oldscalemode = GetScaleMode(idx)
  306.   SetScaleMode idx, 3 ' Pixels
  307.   
  308.   ' Define Standard variables
  309.   If numacross = 0 Then
  310.     VisibleTabs(idx) = NumTabs(idx) + 1
  311.   Else
  312.     VisibleTabs(idx) = numacross
  313.   End If
  314.   
  315.   TabOffset(idx) = (Style \ 256) And &HFF
  316.   If TabOffset(idx) = 0 Then
  317.       Select Case (Style And &HFF)
  318.     Case 0: TabOffset(idx) = 4   ' Chamfered
  319.     Case 1: TabOffset(idx) = 12  ' Slanted
  320.     Case 2: TabOffset(idx) = 0   ' Chicago
  321.     Case Else
  322.         TabOffset(idx) = 4 ' Chamfered
  323.         Style = &H0
  324.       End Select
  325.   Else
  326.       Select Case (Style And &HFF)
  327.     Case 2: TabOffset(idx) = 0   ' Chicago always has TabOffset = 0
  328.         Style = &H2
  329.       End Select
  330.   End If
  331.   TabStyle(idx) = Style
  332.  
  333.   PicturesPosition(idx) = PicPosition
  334.   GrayPictures(idx) = GrayGph
  335.   num_lineas = 1
  336.  
  337.   If (Folders(idx, 0).Alignment Mod 3) = 1 Then Folders(idx, 0).Alignment = 0
  338.   'Modify all the folders to match folder0
  339.   For i = 0 To NumTabs(idx)
  340.     Folders(idx, i).Top = Folders(idx, 0).Top
  341.     Folders(idx, i).Left = Folders(idx, 0).Left
  342.     Folders(idx, i).Width = Folders(idx, 0).Width
  343.     Folders(idx, i).Height = Folders(idx, 0).Height
  344.     Folders(idx, i).BackColor = Folders(idx, 0).BackColor
  345.     'Folders(idx, i).Tag = Folders(idx, i).Caption
  346.     Folders(idx, i).FontBold = False
  347.     Folders(idx, i).FontItalic = Folders(idx, 0).FontItalic
  348.     Folders(idx, i).FontName = Folders(idx, 0).FontName
  349.     Folders(idx, i).FontSize = Folders(idx, 0).FontSize
  350.     Folders(idx, i).FontStrikethru = Folders(idx, 0).FontStrikethru
  351.     Folders(idx, i).FontUnderline = False
  352.     'Folders(idx, i).ForeColor = Folders(idx, 0).ForeColor
  353.     Folders(idx, i).Visible = True
  354.     Folders(idx, i).BevelWidth = 2
  355.     Folders(idx, i).BorderWidth = 2
  356.     Folders(idx, i).BevelInner = 0
  357.     Folders(idx, i).BevelOuter = 2
  358.     Folders(idx, i).Alignment = Folders(idx, 0).Alignment Mod 3
  359.     Folders(idx, i).Outline = True
  360.     Folders(idx, i).ShadowColor = 0
  361.     Folders(idx, i).ZOrder 1
  362.     TabEnabled(idx, i) = True
  363.     
  364.     titulo$ = Folders(idx, i).Caption
  365.     i2 = 1         ' Get accelerator
  366.     accel = 0
  367.     numlin = 1
  368.     While i2 <= Len(titulo$)
  369.     If Mid$(titulo$, i2, 2) = "&&" Then
  370.         i2 = i2 + 2
  371.     ElseIf Mid$(titulo$, i2, 1) = "&" And accel = 0 Then
  372.         accel = i2 + 1
  373.     ElseIf Mid$(titulo$, i2, 2) = "\$" Then
  374.         numlin = numlin + 1
  375.     End If
  376.     i2 = i2 + 1
  377.     Wend
  378.     If numlin > num_lineas Then num_lineas = numlin
  379.     If accel > 0 Then
  380.     TabAccel(idx, i) = Asc(UCase(Mid$(titulo$, accel, 1)))
  381.     Else
  382.     TabAccel(idx, i) = 0
  383.     End If
  384.  
  385.   Next i
  386.   'CurrentTab(idx) = 0  ' Start with the first folder highlighted
  387.          ' If you want a different first folder, use
  388.          '   the GotoFolder function right after you
  389.          '   use DefineFolders
  390.   FolderEnabled(idx) = True
  391.   
  392.   ' Calculate the number of rows needed to display all tabs
  393.   NumRows(idx) = NumTabs(idx) \ VisibleTabs(idx) + 1
  394.   
  395.     ' Set the picture box's properties
  396.     Set FolderTabs(idx) = foldertabcontrol
  397.     Set FolderBorder(idx) = folderbordercontrol
  398.     FolderTabs(idx).Cls
  399.     FolderTabs(idx).AutoSize = False
  400.     FolderTabs(idx).ScaleMode = 3 ' Pixels
  401.     If LeftBorder(idx) Then
  402.     FolderTabs(idx).Left = Folders(idx, 0).Left - (NumRows(idx) - 1) * Abs(RowOffset(idx))
  403.     Else
  404.     FolderTabs(idx).Left = Folders(idx, 0).Left
  405.     End If
  406.     FolderTabs(idx).AutoRedraw = True
  407.     FolderTabs(idx).BackColor = Folders(idx, 0).BackColor
  408.     FolderTabs(idx).BorderStyle = 0
  409.     FolderTabs(idx).DragMode = 0
  410.     FolderTabs(idx).Enabled = True
  411.     FolderTabs(idx).DrawStyle = 0
  412.     FolderTabs(idx).FontBold = Folders(idx, 0).FontBold
  413.     FolderTabs(idx).FontBold = Folders(idx, 0).FontBold
  414.     FolderTabs(idx).FontItalic = Folders(idx, 0).FontItalic
  415.     FolderTabs(idx).FontName = Folders(idx, 0).FontName
  416.     FolderTabs(idx).FontSize = Folders(idx, 0).FontSize
  417.     FolderTabs(idx).FontStrikethru = Folders(idx, 0).FontStrikethru
  418.     FolderTabs(idx).FontUnderline = Folders(idx, 0).FontUnderline
  419.     FolderTabs(idx).ForeColor = Folders(idx, 0).ForeColor
  420.     FolderTabs(idx).LinkMode = 0
  421.     FolderTabs(idx).MousePointer = 0
  422.     FolderTabs(idx).TabStop = False
  423.     FolderTabs(idx).FillStyle = 0
  424.     FolderTabs(idx).FillColor = FolderTabs(idx).Parent.BackColor
  425.     On Error Resume Next ' If FolderContainer dont exists it jumps over the next instruction
  426.     FolderTabs(idx).FillColor = FolderContainer(idx).BackColor
  427.     'FolderTabs(idx).BackColor = FolderTabs(idx).FillColor
  428.     On Error GoTo 0
  429.     FolderTabs(idx).Visible = True
  430.     FolderTabs(idx).ZOrder 0
  431.     TabWidth(idx) = ((Folders(idx, 0).Width - BwTabs * (VisibleTabs(idx) - 1)) \ VisibleTabs(idx))
  432.  
  433.     ' Calculate the tab height based on the height of a sample
  434.     '   letter + the offset height
  435.     texto = FolderTabs(idx).TextHeight("X") * num_lineas
  436.     max = 0
  437.     On Error Resume Next
  438.     For i = 0 To NumTabs(idx) ' get max height of graphics
  439.     If FoldersPictures(idx, i).Height > max Then max = FoldersPictures(idx, i).Height
  440.     FoldersPictures(idx, i).AutoSize = True
  441.     If FoldersPictures(idx, i).Width > TabWidth(idx) Then
  442.     FoldersPictures(idx, i).AutoSize = False
  443.     FoldersPictures(idx, i).Width = TabWidth(idx) - 2 * TabOffset(idx)
  444.     End If
  445.     Next
  446.     On Error GoTo 0
  447.     If PicturesPosition(idx) <= 1 Then ' If it is Left/Right
  448.     If texto > max Then max = texto
  449.     Else
  450.     max = max + texto + TabOffsetConstant
  451.     End If
  452.     OneTabHeight(idx) = max + 2 * TabOffsetConstant
  453.     
  454.     FolderTabs(idx).Height = OneTabHeight(idx) * NumRows(idx) + 3
  455.     FolderTabs(idx).Top = Folders(idx, 0).Top
  456.     
  457.     ' Move down the panels
  458.     For i = 0 To NumTabs(idx)
  459.       Folders(idx, i).Top = FolderTabs(idx).Top + NumRows(idx) * OneTabHeight(idx) - FolderTabs(idx).TextHeight("X")
  460.     Next
  461.   
  462.   FolderTabs(idx).Width = Folders(idx, 0).Width + (NumRows(idx) - 1) * Abs(RowOffset(idx))
  463.  
  464.   ' Configure second picture
  465.   FolderBorder(idx).AutoSize = False
  466.   FolderBorder(idx).ScaleMode = 3 ' Pixels
  467.   FolderBorder(idx).Width = (NumRows(idx) - 1) * Abs(RowOffset(idx))
  468.   If LeftBorder(idx) Then
  469.     FolderBorder(idx).Left = Folders(idx, 0).Left - FolderBorder(idx).Width
  470.   Else
  471.     FolderBorder(idx).Left = Folders(idx, 0).Left + Folders(idx, 0).Width
  472.   End If
  473.   FolderBorder(idx).Top = FolderTabs(idx).Top + FolderTabs(idx).Height
  474.   FolderBorder(idx).Height = Folders(idx, 0).Top + Folders(idx, 0).Height - FolderBorder(idx).Top
  475.   FolderBorder(idx).AutoRedraw = True
  476.   FolderBorder(idx).BackColor = Folders(idx, 0).BackColor
  477.   FolderBorder(idx).BorderStyle = 0
  478.   FolderBorder(idx).DragMode = 0
  479.   FolderBorder(idx).Enabled = True
  480.   FolderBorder(idx).FillStyle = 0
  481.   FolderBorder(idx).FillColor = FolderTabs(idx).FillColor
  482.   FolderBorder(idx).DrawStyle = 0
  483.   FolderBorder(idx).FontBold = Folders(idx, 0).FontBold
  484.   FolderBorder(idx).FontBold = Folders(idx, 0).FontBold
  485.   FolderBorder(idx).FontItalic = Folders(idx, 0).FontItalic
  486.   FolderBorder(idx).FontName = Folders(idx, 0).FontName
  487.   FolderBorder(idx).FontSize = Folders(idx, 0).FontSize
  488.   FolderBorder(idx).FontStrikethru = Folders(idx, 0).FontStrikethru
  489.   FolderBorder(idx).FontUnderline = Folders(idx, 0).FontUnderline
  490.   FolderBorder(idx).ForeColor = Folders(idx, 0).ForeColor
  491.   FolderBorder(idx).LinkMode = 0
  492.   FolderBorder(idx).MousePointer = 0
  493.   FolderBorder(idx).TabStop = False
  494.   FolderBorder(idx).Visible = (NumRows(idx) > 1) And (RowOffset(idx) <> 0)
  495.   FolderBorder(idx).ZOrder 0
  496.  
  497.   If CurrentTab(idx) > NumTabs(idx) Then
  498.     SetFixedControlsToTab idx, 0
  499.     CurrentTab(idx) = 0
  500.   End If
  501.   
  502.   Call ShowFolder(idx)
  503.   
  504.   DefineFolders = True
  505.  
  506.   SetScaleMode idx, oldscalemode
  507.  
  508.   Exit Function
  509. NoIndex:
  510.   Resume Next
  511.  
  512. End Function
  513.  
  514. ' Draws a single folder tab
  515. ' TabNumber = the tab that is being drawn
  516. ' HorPos = the tabs horizontal position on the folders
  517. ' VerPos = the row the tab is on
  518. ' Foreground = True if it is the currently selected tab
  519. Private Sub DrawTab (idx As Integer, TabNumber As Integer, horpos As Integer, verpos As Integer, foreground As Integer)
  520. Dim TabTextWidth As Long
  521. Dim L%, R%, T%, B%
  522.  
  523. Dim titulo As String
  524. Dim ancho_borde3D As Integer
  525. Dim col As Long
  526. Dim i As Integer
  527. Dim accel As Integer
  528. Dim ancho_grafico, ancho_grafico2, alto_grafico, alto_grafico2, alto_texto As Integer
  529. Dim X, y As Integer
  530. Dim xtitulo, ytitulo As Integer
  531. Dim bajo As Integer
  532. Dim resto As Integer
  533. Dim grafico As Control
  534. Dim xp, yp, yy As Integer
  535. Dim ic As Long
  536. Dim lineas_titulo() As String
  537. Dim num_lineas As Integer
  538. Dim last_mark As Integer
  539. Dim accel_line As Integer
  540. Dim pic As Control
  541. Dim n As Integer
  542. Dim offset_tab As Integer
  543. Dim colorborde As Long
  544. Dim alto As Integer
  545. Dim cr As Integer
  546. Dim cg As Integer
  547. Dim cb As Integer
  548. Dim oldscalemode As Integer
  549.  
  550.   oldscalemode = GetScaleMode(idx)
  551.   SetScaleMode idx, 3
  552.  
  553.   If LeftBorder(idx) Then
  554.     offset_tab = (NumRows(idx) - 1) * Abs(RowOffset(idx))
  555.   Else
  556.     offset_tab = 0
  557.   End If
  558.  
  559.   ' Set the Top/Bottom/Left/Right values of the single tab
  560.   T = OneTabHeight(idx) * (NumRows(idx) - verpos)
  561.   B = T + OneTabHeight(idx)
  562.   L = offset_tab + (TabWidth(idx) + BetweenTabs(idx)) * horpos + (verpos - 1) * RowOffset(idx)
  563.   R = L + TabWidth(idx) - 1
  564.   ' In case the tabwidth doesn't adjust perfectly to the number of visible tabs, adjust the last tab end
  565.   If (TabNumber + 1) Mod VisibleTabs(idx) = 0 Then R = offset_tab + Folders(idx, 0).Width + (verpos - 1) * RowOffset(idx) - 1
  566.  
  567.   resto = (NumTabs(idx) \ VisibleTabs(idx)) * VisibleTabs(idx)
  568.   bajo = B
  569.   If Not foreground Then bajo = bajo - 1
  570.   
  571.   ReDim poly(1 To 6) As Coord
  572.   Dim hbrush As Integer
  573.   Dim hrgn As Integer
  574.   Dim bool As Integer
  575.  
  576.   ' Number of vertices in polygon.
  577.   poly(1).X = L
  578.   poly(1).y = bajo + 1
  579.   If (TabStyle(idx) And &HFF) <> 1 Then
  580.     poly(2).X = L
  581.     poly(2).y = T + TabOffset(idx)
  582.   Else
  583.     poly(2).X = poly(1).X
  584.     poly(2).y = poly(1).y
  585.   End If
  586.   poly(3).X = L + TabOffset(idx)
  587.   poly(3).y = T
  588.   poly(4).X = R - TabOffset(idx)
  589.   poly(4).y = T
  590.   If (TabStyle(idx) And &HFF) <> 1 Then
  591.     poly(5).X = R
  592.     poly(5).y = T + TabOffset(idx)
  593.   Else
  594.     poly(5).X = poly(4).X
  595.     poly(5).y = poly(4).y
  596.   End If
  597.   poly(6).X = R
  598.   poly(6).y = bajo + 1
  599.   
  600.   ' Polygon function creates unfilled polygon on screen.
  601.   'bool = Polygon(FolderTabs(idx).hDC, poly(1), 6)
  602.   ' Create brush with fill color
  603.   hbrush = CreateSolidBrush(Folders(idx, TabNumber).FloodColor)
  604.   ' Creates region to fill with color.
  605.   hrgn = CreatePolygonRgn(poly(1), 6, 1) ' 1 = ALTERNATE
  606.   ' If the creation of the region was successful then color.
  607.   If hrgn Then
  608.     If hbrush Then
  609.     bool = FillRgn(FolderTabs(idx).hDC, hrgn, hbrush)
  610.     bool = DeleteObject(hbrush)
  611.     End If
  612.     bool = DeleteObject(hrgn)
  613.   End If
  614.  
  615.   ' Draw the lines around the tab in 3D
  616.   
  617.   ' Draws gray/white border
  618.  
  619.   FolderTabs(idx).PSet (L + 1, bajo), &H80000005
  620.   If (TabStyle(idx) And &HFF) <> 1 Then FolderTabs(idx).Line -(L + 1, T + TabOffset(idx)), &H80000005
  621.   FolderTabs(idx).Line -(L + TabOffset(idx), T + 1), &H80000005
  622.   FolderTabs(idx).Line -(R - TabOffset(idx), T + 1), &H80000005
  623.   If (TabStyle(idx) And &HFF) <> 1 Then FolderTabs(idx).Line -(R - 1, T + TabOffset(idx)), &H80000010
  624.   FolderTabs(idx).Line -(R - 1, bajo + 1), &H80000010
  625.  
  626.   If foreground Then ' Double border if current tab
  627.       FolderTabs(idx).PSet (L + 2 * 1, bajo + 1), &H80000005
  628.       If (TabStyle(idx) And &HFF) <> 1 Then FolderTabs(idx).Line -(L + 2 * 1, T + TabOffset(idx)), &H80000005
  629.       FolderTabs(idx).Line -(L + TabOffset(idx) + 1, T + 2 * 1), &H80000005
  630.       FolderTabs(idx).Line -(R - TabOffset(idx) - 1, T + 2 * 1), &H80000005
  631.       If (TabStyle(idx) And &HFF) <> 1 Then FolderTabs(idx).Line -(R - 2 * 1, T + TabOffset(idx)), &H80000010
  632.       FolderTabs(idx).Line -(R - 2 * 1, bajo + 2 * 1), &H80000010
  633.   End If
  634.   
  635.   ' Draws black tab border
  636.   FolderTabs(idx).PSet (L, bajo), 0
  637.   If (TabStyle(idx) And &HFF) <> 1 Then FolderTabs(idx).Line -(L, T + TabOffset(idx)), 0
  638.   FolderTabs(idx).Line -(L + TabOffset(idx), T), 0
  639.   FolderTabs(idx).Line -(R - TabOffset(idx), T), 0
  640.   If (TabStyle(idx) And &HFF) <> 1 Then FolderTabs(idx).Line -(R, T + TabOffset(idx)), 0
  641.   FolderTabs(idx).Line -(R, bajo + 1), 0
  642.  
  643.   ' If it is the selected folder or the first of a row, draw a grey line underneath
  644.   If foreground Then
  645.     FolderTabs(idx).DrawWidth = 3
  646.     FolderTabs(idx).Line (R - 4 * 1, B + 1)-(L + 4 * 1, B + 1), Folders(idx, 0).BackColor
  647.     FolderTabs(idx).DrawWidth = 1
  648.   ElseIf (TabNumber Mod VisibleTabs(idx) = 0 And verpos > 1) Then
  649.     FolderTabs(idx).DrawWidth = 3
  650.     FolderTabs(idx).Line (R - 3 * 1, B + 1)-(L + 3 * 1, B + 1), Folders(idx, 0).BackColor
  651.     FolderTabs(idx).DrawWidth = 1
  652.   End If
  653.   ' Print the tab's title (bold if foreground)
  654.   
  655.   FolderTabs(idx).FontBold = foreground
  656.   titulo$ = Folders(idx, TabNumber).Caption & "\$"
  657.   
  658.   num_lineas = 0
  659.   last_mark = 0
  660.   i = 1         ' Removes &&, gets accelerator and divide in lines
  661.   accel = 0
  662.   While i <= Len(titulo$)
  663.     If Mid$(titulo$, i, 2) = "&&" Then
  664.     titulo$ = Left$(titulo$, i) & Mid$(titulo$, i + 2)
  665.     i = i + 1
  666.     ElseIf Mid$(titulo$, i, 1) = "&" And accel = 0 Then
  667.     titulo$ = Left$(titulo$, i - 1) & Mid$(titulo$, i + 1)
  668.     accel = i
  669.     accel_line = num_lineas + 1
  670.     ElseIf Mid$(titulo$, i, 2) = "\$" Then
  671.     num_lineas = num_lineas + 1
  672.     ReDim Preserve lineas_titulo$(1 To num_lineas)
  673.     lineas_titulo$(num_lineas) = Mid$(titulo$, last_mark + 1, i - last_mark - 1)
  674.     last_mark = i + 1
  675.     End If
  676.     i = i + 1
  677.   Wend
  678.  
  679.   ancho_grafico = 0
  680.   On Error Resume Next
  681.   If FoldersPictures(idx, TabNumber).Picture <> 0 Then
  682.     ancho_grafico = FoldersPictures(idx, TabNumber).Width
  683.   End If
  684.   ancho_grafico2 = ancho_grafico
  685.   If PicturesPosition(idx) > 1 Then ancho_grafico2 = 0
  686.  
  687.   If ancho_grafico > 0 Then
  688.     alto_grafico = FoldersPictures(idx, TabNumber).Height
  689.     If titulo$ <> "\$" Then
  690.     Select Case PicturesPosition(idx)
  691.         Case 0 ' Left
  692.             X = (L + TabOffset(idx) + TabOffsetConstant)
  693.             y = (T + (OneTabHeight(idx) - alto_grafico) \ 2)
  694.         Case 1 ' Right
  695.             X = (R - ancho_grafico - TabOffset(idx) - TabOffsetConstant)
  696.             y = (T + (OneTabHeight(idx) - alto_grafico) \ 2)
  697.         Case 2 ' Top
  698.             X = (L + (TabWidth(idx) - ancho_grafico) \ 2)
  699.             y = (T + 2 * TabOffsetConstant)
  700.         Case 3 ' Bottom
  701.             X = (L + (TabWidth(idx) - ancho_grafico) \ 2)
  702.             y = (B - alto_grafico - TabOffsetConstant)
  703.     End Select
  704.     Else
  705.     X = (L + (TabWidth(idx) - ancho_grafico) \ 2)
  706.     y = (T + (OneTabHeight(idx) - alto_grafico) \ 2)
  707.     End If
  708.     ancho_grafico2 = ancho_grafico
  709.     alto_grafico2 = alto_grafico
  710.     i = bitblt(FolderTabs(idx).hDC, X, y, ancho_grafico2, alto_grafico2, FoldersPictures(idx, TabNumber).hDC, 0, 0, &HCC0020)
  711.     If GrayPictures(idx) And Not TabEnabled(idx, TabNumber) Or Not FolderEnabled(idx) Then
  712.     ' gray graphic
  713.     Set pic = FolderTabs(idx)
  714.     Dim hbmp As Integer
  715.     Dim hbr As Integer
  716.     Dim hbrprev As Integer
  717.     Dim graypattern As String
  718.     Const PATPAINT = &HFB0A09
  719.     Const PATCOPY = &HF00021
  720.     Const PATINVERT = &H5A0049
  721.     Const GRAYCODE = &HFA0089
  722.     graypattern = ""
  723.     For yp = 1 To alto_grafico2 \ 2
  724.         For xp = 1 To ancho_grafico2 \ 8
  725.         graypattern = graypattern & Chr$(&H55)
  726.         Next
  727.         For xp = 1 To ancho_grafico2 \ 8
  728.         graypattern = graypattern & Chr$(&HAA)
  729.         Next
  730.     Next
  731.     hbmp = CreateBitmap(8 * (ancho_grafico2 \ 8), 2 * (alto_grafico2 \ 2), 1, 1, ByVal graypattern)
  732.     hbr = CreatePatternBrush(hbmp)
  733.     hbrprev = SelectObject(pic.hDC, hbr)
  734.     i = PatBlt(pic.hDC, X, y, ancho_grafico2, alto_grafico2, GRAYCODE)
  735.     i = SelectObject(pic.hDC, hbrprev)
  736.     i = DeleteObject(hbr)
  737.     i = DeleteObject(hbmp)
  738.     End If
  739.   End If
  740.   
  741.   If Not TabEnabled(idx, TabNumber) Or Not FolderEnabled(idx) Then
  742.     FolderTabs(idx).ForeColor = &H808080
  743.   Else
  744.     FolderTabs(idx).ForeColor = Folders(idx, TabNumber).ForeColor
  745.   End If
  746.   
  747.   For i = 1 To num_lineas
  748.       titulo$ = Trim$(lineas_titulo$(i))
  749.       Do
  750.       TabTextWidth = FolderTabs(idx).TextWidth(titulo$)
  751.       If TabTextWidth + ancho_grafico + 2 * (TabOffset(idx) + TabOffsetConstant) >= TabWidth(idx) Then titulo$ = Trim$(Left$(titulo$, Len(titulo$) - 1))
  752.       Loop Until TabTextWidth + ancho_grafico + 2 * (TabOffset(idx) + TabOffsetConstant) < TabWidth(idx) Or TabTextWidth = 0 Or titulo$ = ""
  753.       On Error GoTo 0
  754.       alto_texto = FolderTabs(idx).TextHeight(titulo$)
  755.       If ancho_grafico > 0 Then
  756.         Select Case PicturesPosition(idx)
  757.         Case 0 ' Left
  758.             xtitulo = L + TabOffset(idx) + TabOffsetConstant + ancho_grafico + (TabWidth(idx) - 2 * (TabOffset(idx) + TabOffsetConstant) - ancho_grafico - TabTextWidth) \ 2
  759.             ytitulo = T + (OneTabHeight(idx) - num_lineas * alto_texto) \ 2 + (i - 1) * alto_texto
  760.         Case 1 ' Right
  761.             xtitulo = L + TabOffset(idx) + TabOffsetConstant + (TabWidth(idx) - 2 * (TabOffset(idx) + TabOffsetConstant) - ancho_grafico - TabTextWidth) \ 2
  762.             ytitulo = T + (OneTabHeight(idx) - num_lineas * alto_texto) \ 2 + (i - 1) * alto_texto
  763.         Case 2 ' Top
  764.             xtitulo = L + (TabWidth(idx) - TabTextWidth) \ 2
  765.             ytitulo = T + alto_grafico + TabOffsetConstant + (OneTabHeight(idx) - alto_grafico - TabOffsetConstant - num_lineas * alto_texto) \ 2 + (i - 1) * alto_texto
  766.         Case 3 ' Bottom
  767.             xtitulo = L + (TabWidth(idx) - TabTextWidth) \ 2
  768.             ytitulo = T + (OneTabHeight(idx) - alto_grafico - TabOffsetConstant - num_lineas * alto_texto) \ 2 + (i - 1) * alto_texto
  769.         End Select
  770.       Else
  771.     xtitulo = L + (TabWidth(idx) - TabTextWidth) \ 2
  772.     ytitulo = T + (OneTabHeight(idx) - num_lineas * alto_texto) \ 2 + (i - 1) * alto_texto
  773.       End If
  774.     
  775.       FolderTabs(idx).CurrentX = xtitulo
  776.       FolderTabs(idx).CurrentY = ytitulo
  777.       
  778.       If accel > 0 And accel_line = i Then
  779.     FolderTabs(idx).Print Left$(titulo$, accel - 1);
  780.     FolderTabs(idx).FontUnderline = True
  781.     FolderTabs(idx).Print Mid$(titulo$, accel, 1);
  782.     FolderTabs(idx).FontUnderline = False
  783.     FolderTabs(idx).Print Mid$(titulo$, accel + 1);
  784.       Else
  785.     FolderTabs(idx).Print titulo$
  786.       End If
  787.   Next
  788.  
  789.   FolderTabs(idx).ForeColor = col
  790.   FolderTabs(idx).FontBold = False
  791.  
  792.   SetScaleMode idx, oldscalemode
  793.  
  794. End Sub
  795.  
  796. ' Draws each of the visible tabs on screen
  797. Private Sub DrawTabs (idx As Integer)
  798.     Dim i As Integer
  799.     Dim a As Integer
  800.     Dim quita As Integer
  801.     Dim X As Integer
  802.     Dim y As Integer
  803.     Dim ancho As Integer
  804.     Dim alto As Integer
  805.     Dim alto2 As Integer
  806.     Dim offset_tab As Integer
  807.     Dim trocitoalto As Integer
  808.     Dim max_verpos As Integer
  809.     Dim vp As Integer
  810.     Dim ic As Long
  811.     Dim oldscalemode As Integer
  812.  
  813.   oldscalemode = GetScaleMode(idx)
  814.   SetScaleMode idx, 3
  815.  
  816.   If LeftBorder(idx) And NumRows(idx) > 1 Then
  817.     offset_tab = (NumRows(idx) - 1) * Abs(RowOffset(idx))
  818.   Else
  819.     offset_tab = 0
  820.   End If
  821.   FolderTabs(idx).Cls
  822.   FolderBorder(idx).Cls
  823.  
  824.   ' Draws lines at folderborder and under tabs
  825.   If NumRows(idx) > 1 Then
  826.       ancho = Abs(RowOffset(idx))
  827.       For i = 1 To NumRows(idx) - 1
  828.       X = Abs(RowOffset(idx)) * (i - 1) - 1
  829.       alto = FolderBorder(idx).Height - 1 - i * OneTabHeight(idx)
  830.       alto2 = FolderTabs(idx).Height - 4 - i * OneTabHeight(idx)
  831.       
  832.       If RowOffset(idx) <> 0 Then
  833.           ' black lines at border
  834.           If LeftBorder(idx) Then
  835.           FolderBorder(idx).Line (offset_tab - X - 2, alto)-Step(-ancho + 1, 0), 0' Horiz border
  836.           FolderBorder(idx).Line -Step(0, -alto - 1), 0' Vert border
  837.           FolderTabs(idx).Line (offset_tab - X - ancho - 1, FolderTabs(idx).Height)-Step(0, alto2 - FolderTabs(idx).Height), 0' cont Vert
  838.           Else
  839.           FolderBorder(idx).Line (X + 1, alto)-Step(ancho - 1, 0), 0' Horiz border
  840.           FolderBorder(idx).Line -Step(0, -alto - 1), 0      ' Vert border
  841.           FolderTabs(idx).Line (offset_tab + Folders(idx, 0).Width + X + ancho, FolderTabs(idx).Height)-(offset_tab + Folders(idx, 0).Width + X + ancho, alto2), 0' cont Vert
  842.           End If
  843.           
  844.           ' same with gray/white
  845.           If LeftBorder(idx) Then
  846.           FolderBorder(idx).Line (offset_tab - X - 2, alto - 1)-Step(-ancho + 2, 0), &H80000010
  847.           FolderBorder(idx).Line -Step(0, -alto), &H80000005
  848.           FolderTabs(idx).Line (offset_tab - (X + ancho), FolderTabs(idx).Height)-(offset_tab - (X + ancho), alto2), &H80000005
  849.           Else
  850.           FolderBorder(idx).Line (X, alto - 1)-Step(ancho - 1, 0), &H80000010
  851.           FolderBorder(idx).Line -Step(0, -alto), &H80000010
  852.           FolderTabs(idx).Line (offset_tab + Folders(idx, 0).Width + X + ancho - 1, FolderTabs(idx).Height)-(offset_tab + Folders(idx, 0).Width + X + ancho - 1, alto2), &H80000010
  853.           End If
  854.       End If
  855.  
  856.       ' black page border line
  857.       FolderTabs(idx).Line (offset_tab + i * RowOffset(idx), alto2 + 1 + OneTabHeight(idx))-Step(0, -OneTabHeight(idx)), 0
  858.       FolderTabs(idx).Line -Step(1, 0), 0
  859.       FolderTabs(idx).Line -Step(1, 0), &H80000005
  860.       FolderTabs(idx).Line -Step(Folders(idx, 0).Width - 3, 0), 0
  861.       FolderTabs(idx).Line -Step(0, OneTabHeight(idx)), 0
  862.       ' gray/white page border line
  863.       FolderTabs(idx).Line (offset_tab + i * RowOffset(idx) + 1, alto2 + 1 + OneTabHeight(idx))-Step(0, -OneTabHeight(idx) + 1), &H80000005
  864.       FolderTabs(idx).Line -Step(Folders(idx, 0).Width - 3, 0), &H80000005
  865.       FolderTabs(idx).Line -Step(0, OneTabHeight(idx) - 1), &H80000010
  866.       Next
  867.   End If
  868.   ' Draws the 3D line below first row of tabs
  869.   If VisibleTabs(idx) > 1 Then
  870.       FolderTabs(idx).Line (offset_tab + 1, FolderTabs(idx).Height - 3)-(offset_tab + Folders(idx, 0).Width, FolderTabs(idx).Height - 3), 0
  871.       FolderTabs(idx).Line (offset_tab + 2, FolderTabs(idx).Height - 2)-(offset_tab + Folders(idx, 0).Width - 1, FolderTabs(idx).Height - 2), &H80000005
  872.       FolderTabs(idx).Line (offset_tab + 3, FolderTabs(idx).Height - 1)-(offset_tab + Folders(idx, 0).Width - 2, FolderTabs(idx).Height - 1), &H80000005
  873.   End If
  874.  
  875.   ' Draw lines down the left and right side in the first row
  876.   If (NumTabs(idx) + 1) Mod VisibleTabs(idx) = 0 Then
  877.     alto = 3  ' No empty tabs
  878.   ElseIf RowOffset(idx) <> 0 Then
  879.     alto = 3                    ' Empty Tabs and RowOffset<>0
  880.   Else
  881.     alto = OneTabHeight(idx) + 3 ' Empty Tabs and RowOffset=0
  882.   End If
  883.   FolderTabs(idx).Line (offset_tab, FolderTabs(idx).Height - alto)-(offset_tab, FolderTabs(idx).Height), 0
  884.   FolderTabs(idx).Line (offset_tab + 1, FolderTabs(idx).Height - alto)-(offset_tab + 1, FolderTabs(idx).Height), &H80000005
  885.   FolderTabs(idx).Line (offset_tab + 2, FolderTabs(idx).Height - 2)-(offset_tab + 2, FolderTabs(idx).Height), &H80000005
  886.   
  887.   If LeftBorder(idx) And CurrentTab(idx) + 1 > ((NumTabs(idx) + 1) \ VisibleTabs(idx)) * VisibleTabs(idx) Then
  888.     alto = OneTabHeight(idx) + 3 ' Right border size if Partial row is current
  889.   End If
  890.   
  891.   If LeftBorder(idx) And (CurrentTab(idx) + 1) Mod VisibleTabs(idx) <> 0 Then
  892.     trocitoalto = 3
  893.   Else
  894.     trocitoalto = 0
  895.   End If
  896.   
  897.   ' Panel little right corner
  898.   FolderTabs(idx).Line (offset_tab + Folders(idx, 0).Width - 3, FolderTabs(idx).Height - 2)-(offset_tab + Folders(idx, 0).Width - 3, FolderTabs(idx).Height - trocitoalto), &H80000010
  899.   FolderTabs(idx).Line (offset_tab + Folders(idx, 0).Width - 2, FolderTabs(idx).Height - 2)-(offset_tab + Folders(idx, 0).Width - 2, FolderTabs(idx).Height - trocitoalto), &H80000010
  900.   FolderTabs(idx).Line (offset_tab + Folders(idx, 0).Width - 1, FolderTabs(idx).Height - 2)-(offset_tab + Folders(idx, 0).Width - 1, FolderTabs(idx).Height - trocitoalto), 0
  901.  
  902.   ' Draw each tab in order of depth
  903.   max_verpos = NumTabs(idx) \ VisibleTabs(idx) + 1
  904.   For vp = max_verpos To 1 Step -1
  905.       For i = NumTabs(idx) To 0 Step -1
  906.     If VerTabPos(idx, i) = vp Then DrawTab idx, i, HorTabPos(idx, i), vp, False
  907.       Next i
  908.   Next vp
  909.   DrawTab idx, CurrentTab(idx), HorTabPos(idx, CurrentTab(idx)), VerTabPos(idx, CurrentTab(idx)), True
  910.  
  911.   ' Fills the corners with the forms (or container) color
  912.   
  913.   ' Fill the bottom corner
  914.   If NumRows(idx) > 1 And RowOffset(idx) <> 0 Then
  915.     i = ExtFloodFill(FolderBorder(idx).hDC, 0, (FolderBorder(idx).Height) - 1, FolderBorder(idx).BackColor, FLOODFILLSURFACE)
  916.   End If
  917.   ' Fill the top corners
  918.   i = ExtFloodFill(FolderTabs(idx).hDC, 0, 0, FolderTabs(idx).BackColor, FLOODFILLSURFACE)
  919.   i = ExtFloodFill(FolderTabs(idx).hDC, (FolderTabs(idx).Width) - 1, 0, FolderTabs(idx).BackColor, FLOODFILLSURFACE)
  920.   ' Fill the little right corner of each Tab if it exists
  921.   If TabOffset(idx) + BetweenTabs(idx) >= 0 Then
  922.       For a = 1 To VisibleTabs(idx) - 1
  923.     i = ExtFloodFill(FolderTabs(idx).hDC, offset_tab + (NumRows(idx) - 1) * RowOffset(idx) + a * (TabWidth(idx) + BetweenTabs(idx)) - (BetweenTabs(idx) \ 2), 0, FolderTabs(idx).BackColor, FLOODFILLSURFACE)
  924.       Next
  925.   End If
  926.   
  927.   SetScaleMode idx, oldscalemode
  928.  
  929. End Sub
  930.  
  931. Sub FolderClick (idx As Integer, button As Integer, X As Single, y As Single)
  932.     Dim i As Integer
  933.     i = FolderClickFn(idx, button, X, y)
  934. End Sub
  935.  
  936. Function FolderClicked (idx As Integer, X As Single, y As Single) As Integer
  937. Dim horpos As Integer
  938. Dim verpos As Integer
  939. Dim offs As Integer
  940. Dim offset_tab As Integer
  941. Dim oldscalemode As Integer
  942.  
  943.   oldscalemode = GetScaleMode(idx)
  944.   SetScaleMode idx, 3
  945.   
  946.   If LeftBorder(idx) And RowOffset(idx) <> 0 And NumRows(idx) > 1 Then
  947.     offset_tab = FolderBorder(idx).Width
  948.   Else
  949.     offset_tab = 0
  950.   End If
  951.   verpos = NumRows(idx) - (y \ OneTabHeight(idx)) - 1
  952.   offs = verpos * RowOffset(idx)
  953.   If X - offset_tab - offs > Folders(idx, 0).Width Or X - offset_tab - offs < 0 Then
  954.     FolderClicked = -1
  955.     SetScaleMode idx, oldscalemode
  956.     Exit Function
  957.   End If
  958.   verpos = (verpos + (CurrentTab(idx) \ VisibleTabs(idx) + 1)) Mod NumRows(idx) - 1
  959.   If verpos = -1 Then verpos = NumRows(idx) - 1
  960.   horpos = (X - offset_tab - offs) \ ((FolderTabs(idx).Width - Abs(RowOffset(idx)) * (NumRows(idx) - 1)) \ VisibleTabs(idx))
  961.   FolderClicked = (verpos * VisibleTabs(idx)) + horpos
  962.   
  963.   SetScaleMode idx, oldscalemode
  964.  
  965. End Function
  966.  
  967. ' Jump to the folder tab that was clicked on
  968. ' This is called by the Tab picture box's MouseDown procedure
  969. Function FolderClickFn (idx As Integer, button As Integer, X As Single, y As Single) As Integer
  970.   Dim Folder As Integer
  971.   Folder = FolderClicked(idx, X, y)
  972.   If Folder = -1 Then Exit Function
  973.  
  974.   If Not TabEnabled(idx, Folder) Then
  975.     FolderClickFn = -1
  976.     Exit Function
  977.   End If
  978.  
  979.   GotoFolder idx, Folder
  980.   FolderClickFn = Folder
  981.  
  982. End Function
  983.  
  984. Sub FolderDisable (Index As Integer)
  985.     Dim a As Integer
  986.     FolderEnabled(Index) = False
  987.     For a = 0 To NumTabs(Index)
  988.     Folders(Index, a).Enabled = False
  989.     Next
  990.     FolderTabs(Index).Enabled = False
  991.     FolderBorder(Index).Enabled = False
  992.     ShowFolder Index
  993. End Sub
  994.  
  995. Sub FolderEnable (Index As Integer)
  996.     Dim a As Integer
  997.     FolderEnabled(Index) = True
  998.     For a = 0 To NumTabs(Index)
  999.     Folders(Index, a).Enabled = True
  1000.     Next
  1001.     FolderTabs(Index).Enabled = True
  1002.     FolderBorder(Index).Enabled = True
  1003.     ShowFolder Index
  1004. End Sub
  1005.  
  1006. Function FolderHeight (idx As Integer) As Integer
  1007. Dim oldscalemode As Integer
  1008.  
  1009.   oldscalemode = GetScaleMode(idx)
  1010.   SetScaleMode idx, 3
  1011.     FolderHeight = FolderTabs(idx).Height + FolderBorder(idx).Height
  1012.   SetScaleMode idx, oldscalemode
  1013. End Function
  1014.  
  1015. Function FolderLeft (idx As Integer) As Integer
  1016. Dim oldscalemode As Integer
  1017.  
  1018.   oldscalemode = GetScaleMode(idx)
  1019.   SetScaleMode idx, 3
  1020.     FolderLeft = FolderTabs(idx).Left
  1021.   SetScaleMode idx, oldscalemode
  1022. End Function
  1023.  
  1024. Sub FolderMove (idx As Integer, X As Single, y As Single)
  1025.     Dim a As Integer
  1026.     Dim subleft As Integer
  1027.     Dim subtop As Integer
  1028.     Dim oldscalemode As Integer
  1029.  
  1030.   oldscalemode = GetScaleMode(idx)
  1031.   SetScaleMode idx, 3
  1032.  
  1033.     ' Enable the folder
  1034.     FolderEnabled(idx) = True
  1035.     For a = 0 To NumTabs(idx)
  1036.     Folders(idx, a).Enabled = True
  1037.     TabEnabled(idx, a) = True
  1038.     Next
  1039.     FolderTabs(idx).Enabled = True
  1040.     FolderBorder(idx).Enabled = True
  1041.  
  1042.     ' Move it
  1043.     subleft = FolderLeft(idx)
  1044.     subtop = FolderTop(idx)
  1045.     
  1046.     FolderTabs(idx).Move FolderTabs(idx).Left - subleft, FolderTabs(idx).Top - subtop
  1047.     FolderBorder(idx).Move FolderBorder(idx).Left - subleft, FolderBorder(idx).Top - subtop
  1048.     For a = 0 To NumTabs(idx)
  1049.     Folders(idx, a).Move Folders(idx, a).Left - subleft, Folders(idx, a).Top - subtop
  1050.     Next
  1051.  
  1052.     SetScaleMode idx, oldscalemode
  1053.     ShowFolder idx
  1054. End Sub
  1055.  
  1056. Function FolderTop (idx As Integer) As Integer
  1057. Dim oldscalemode As Integer
  1058.  
  1059.   oldscalemode = GetScaleMode(idx)
  1060.   SetScaleMode idx, 3
  1061.     FolderTop = FolderTabs(idx).Top
  1062.   SetScaleMode idx, oldscalemode
  1063. End Function
  1064.  
  1065. Function FolderWidth (idx As Integer) As Integer
  1066. Dim oldscalemode As Integer
  1067.  
  1068.   oldscalemode = GetScaleMode(idx)
  1069.   SetScaleMode idx, 3
  1070.     FolderWidth = FolderTabs(idx).Width
  1071.   SetScaleMode idx, oldscalemode
  1072. End Function
  1073.  
  1074. Private Function GetScaleMode (idx As Integer) As Integer
  1075.     GetScaleMode = Folders(idx, 0).Parent.ScaleMode
  1076.     On Error Resume Next
  1077.     GetScaleMode = FolderContainer(idx).ScaleMode
  1078.     On Error GoTo 0
  1079. End Function
  1080.  
  1081. ' Make FolderNumber the active folder
  1082. Sub GotoFolder (idx As Integer, FolderNumber As Integer)
  1083.   If CurrentTab(idx) = FolderNumber Then Exit Sub
  1084.   If (FolderNumber >= 0) And (FolderNumber <= NumTabs(idx)) Then
  1085.     SetFixedControlsToTab idx, FolderNumber
  1086.     CurrentTab(idx) = FolderNumber
  1087.     ShowFolder idx
  1088.   End If
  1089. End Sub
  1090.  
  1091. Function GotoFolderByAccel (idx As Integer, ByVal keycode As Integer, ByVal shift As Integer) As Integer
  1092.     Dim i As Integer
  1093.     Dim TabNumber As Integer
  1094.     If shift <> 4 Or keycode = 0 Then Exit Function' No ALT-
  1095.     i = 0
  1096.     TabNumber = -1
  1097.     While i <= NumTabs(idx) And TabNumber = -1
  1098.     If TabAccel(idx, i) = UCase(keycode) Then TabNumber = i
  1099.     i = i + 1
  1100.     Wend
  1101.     If TabNumber <> -1 Then
  1102.     GotoFolderByAccel = 0
  1103.     If TabNumber <> CurrentTab(idx) And TabEnabled(idx, TabNumber) Then GotoFolder idx, TabNumber
  1104.     Else
  1105.     GotoFolderByAccel = keycode
  1106.     End If
  1107. End Function
  1108.  
  1109. ' Calculate the column of a particular tab
  1110. Private Function HorTabPos (idx As Integer, TN As Integer) As Integer
  1111.   
  1112.   HorTabPos = TN Mod VisibleTabs(idx)
  1113.  
  1114. End Function
  1115.  
  1116. ' Moves to the next folder
  1117. Sub NextFolder (idx As Integer)
  1118.  
  1119.   CurrentTab(idx) = ((CurrentTab(idx) + 1) Mod (NumTabs(idx) + 1))
  1120.   ShowFolder idx
  1121.  
  1122. End Sub
  1123.  
  1124. ' Move to the previous folder
  1125. Sub PrevFolder (idx As Integer)
  1126.   
  1127.   If CurrentTab(idx) = 0 Then
  1128.     CurrentTab(idx) = NumTabs(idx)
  1129.   Else
  1130.     CurrentTab(idx) = CurrentTab(idx) - 1
  1131.   End If
  1132.   ShowFolder idx
  1133.  
  1134. End Sub
  1135.  
  1136. Function ReDefineFolders (idx As Integer, numacross As Integer, Style As Integer, RowOffs As Integer, PicPosition As Integer, GrayGph As Integer, LeftBdr As Integer, BwTabs As Integer) As Integer
  1137. Dim oldscalemode As Integer
  1138.  
  1139.   oldscalemode = GetScaleMode(idx)
  1140.   SetScaleMode idx, 3
  1141.     
  1142.     Folders(idx, CurrentTab(idx)).Visible = False
  1143.     FolderTabs(idx).Visible = False
  1144.     FolderBorder(idx).Visible = False
  1145.     Folders(idx, 0).Top = Folders(idx, 0).Top - (NumRows(idx) * OneTabHeight(idx) - FolderTabs(idx).TextHeight("X"))
  1146.     ReDefineFolders = DefineFolders(idx, numacross, Folders(idx, 0), (Folders(idx, 0).Tag), FolderTabs(idx), FolderBorder(idx), FolderContainer(idx), Style, RowOffs, PicPosition, GrayGph, LeftBdr, BwTabs)
  1147.   
  1148.   SetScaleMode idx, oldscalemode
  1149. End Function
  1150.  
  1151. Sub ResetFixedControls (idx As Integer)
  1152.     SetFixedControlsToTab idx, 0
  1153. End Sub
  1154.  
  1155. Sub SetFixedControl (idx As Integer, c As Control)
  1156.     Dim hay_error As Integer
  1157.     Dim n As Integer
  1158.     If NumFixedControls(idx) = MaxFixedControls Then Exit Sub
  1159.     hay_error = False
  1160.     On Error GoTo 1
  1161.     n = c.hWnd
  1162.     On Error GoTo 0
  1163.     If hay_error Then Exit Sub
  1164.     'If TypeOf c Is Label Then Exit Sub
  1165.     'If TypeOf c Is Shape Then Exit Sub
  1166.     'If TypeOf c Is Line Then Exit Sub
  1167.     'If TypeOf c Is Image Then Exit Sub
  1168.     NumFixedControls(idx) = NumFixedControls(idx) + 1
  1169.     Set FixedControls(idx, NumFixedControls(idx)) = c
  1170.     Exit Sub
  1171. 1 :
  1172.     hay_error = True
  1173.     Resume Next
  1174. End Sub
  1175.  
  1176. Private Sub SetFixedControlsToTab (idx As Integer, FolderNumber As Integer)
  1177.     Dim a, ret, estado_enabled, HandleChild As Integer
  1178.     For a = 1 To NumFixedControls(idx)
  1179.     If Not TabEnabled(idx, CurrentTab(idx)) Then
  1180.         Folders(idx, CurrentTab(idx)).Enabled = True
  1181.     End If
  1182.     estado_enabled = FixedControls(idx, a).Enabled
  1183.     If Not estado_enabled Then FixedControls(idx, a).Enabled = True
  1184.     'If TypeOf FixedControls(idx, a) Is ... Then
  1185.     '    FixedControls(idx, a).SetFocus
  1186.     '    HandleChild = getfocus()
  1187.     '    ret = setparent(HandleChild, Folders(idx, FolderNumber).hWnd)
  1188.     'Else
  1189.         ret = setparent(FixedControls(idx, a).hWnd, Folders(idx, FolderNumber).hWnd)
  1190.     'End If
  1191.     If Not estado_enabled Then FixedControls(idx, a).Enabled = False
  1192.     If Not TabEnabled(idx, CurrentTab(idx)) Then
  1193.         Folders(idx, CurrentTab(idx)).Enabled = False
  1194.     End If
  1195.     Next
  1196. End Sub
  1197.  
  1198. Private Sub SetScaleMode (idx As Integer, mode As Integer)
  1199.   Dim flag As Integer
  1200.   Dim n As Integer
  1201.   flag = False
  1202.   On Error GoTo hay_error ' check if exists a container
  1203.   n = FolderContainer(idx).Left
  1204.   On Error GoTo 0
  1205.   If flag Then
  1206.     Folders(idx, 0).Parent.ScaleMode = mode
  1207.   Else
  1208.     On Error GoTo hay_error ' check if the container has an ScaleMode prop.
  1209.     FolderContainer(idx).ScaleMode = mode
  1210.     On Error GoTo 0
  1211.     If flag Then
  1212.     MsgBox "Folder " & Format$(idx) & " Container doesn't have an ScaleMode property.", 16, "ERROR"
  1213.     End
  1214.     End If
  1215.   End If
  1216.   Exit Sub
  1217. hay_error:
  1218.   flag = True
  1219.   Resume Next
  1220. End Sub
  1221.  
  1222. ' Makes the current folder visible
  1223. ' Then updates the tabs
  1224. Private Sub ShowFolder (idx As Integer)
  1225. Dim i As Integer
  1226.  
  1227.   For i = 0 To NumTabs(idx)
  1228.     Folders(idx, i).Enabled = True
  1229.   Next i
  1230.   DrawTabs idx
  1231.   For i = 0 To NumTabs(idx)
  1232.     Folders(idx, i).Enabled = TabEnabled(idx, i) And FolderEnabled(idx)
  1233.   Next i
  1234.   ' No flickering (or less) if put this here
  1235.   Folders(idx, CurrentTab(idx)).Visible = True
  1236.   For i = 0 To NumTabs(idx)
  1237.     Folders(idx, i).Visible = (i = CurrentTab(idx))
  1238.   Next i
  1239.  
  1240. End Sub
  1241.  
  1242. Sub TabDisable (idx As Integer, TabNumber As Integer)
  1243.     TabEnabled(idx, TabNumber) = False
  1244.     ShowFolder idx
  1245. End Sub
  1246.  
  1247. Sub TabEnable (idx As Integer, TabNumber As Integer)
  1248.     TabEnabled(idx, TabNumber) = True
  1249.     ShowFolder idx
  1250. End Sub
  1251.  
  1252. ' Moves the whole tab thingy to the top left corner of the
  1253. '   form, and then shrinks the form to fit perfectly.
  1254. Sub TightenForm (idx As Integer, BelowSpace As Integer, noborders As Integer)
  1255. Dim SB As Long
  1256. Dim CH As Integer
  1257. Dim MH As Integer
  1258. Dim OY As Long, OX As Long
  1259. Dim leftinit As Integer
  1260.  
  1261.   SB = 0
  1262.   On Error GoTo EsForm
  1263.   CH = (FolderContainer(idx).Width <> 0)
  1264.   On Error GoTo 0
  1265.   GoTo Continua
  1266. EsForm:
  1267.   SB = 1
  1268.   Resume Next
  1269. Continua:
  1270.   If SB = 0 Then Exit Sub
  1271.   
  1272. Dim oldscalemode As Integer
  1273.  
  1274.   oldscalemode = GetScaleMode(idx)
  1275.   SetScaleMode idx, 3
  1276.  
  1277.   If noborders Then
  1278.     leftinit = -3
  1279.     If BelowSpace = 0 Then BelowSpace = -2
  1280.   Else
  1281.     leftinit = 0
  1282.   End If
  1283.   FolderBorder(idx).Left = FolderBorder(idx).Left - FolderTabs(idx).Left + leftinit
  1284.   For CH = 0 To NumTabs(idx)
  1285.     Folders(idx, CH).Left = Folders(idx, CH).Left - FolderTabs(idx).Left + leftinit
  1286.   Next CH
  1287.   FolderTabs(idx).Left = leftinit
  1288.   
  1289.   ' Find the height of the caption
  1290.   CH = getsystemmetrics(4)
  1291.  
  1292.   ' Is there a menu?
  1293.   If GetMenu(CInt(FolderTabs(idx).Parent.hWnd)) <> 0 Then
  1294.     MH = getsystemmetrics(15)  ' Get the menu's height
  1295.     Select Case FolderTabs(idx).Parent.BorderStyle
  1296.       Case 2    ' Sizable
  1297.     SB = 2 * getsystemmetrics(32)
  1298.       Case Else ' Little known fact: with a menu, your window's
  1299.         '   borders can only be sizable or single.
  1300.     SB = 2 * getsystemmetrics(5)
  1301.     End Select
  1302.     OY = -1
  1303.   Else
  1304.     Select Case FolderTabs(idx).Parent.BorderStyle
  1305.       Case 0
  1306.     SB = 0
  1307.     CH = 0
  1308.       Case 1
  1309.     SB = 2 * getsystemmetrics(5)
  1310.     OY = -1
  1311.       Case 2
  1312.     SB = 2 * getsystemmetrics(32)
  1313.     OY = -1
  1314.       Case 3
  1315.     SB = 2 * getsystemmetrics(7)
  1316.     OX = 2
  1317.     OY = 1
  1318.     End Select
  1319.   
  1320.   End If
  1321.  
  1322.   FolderTabs(idx).Parent.Height = Folders(idx, 0).Top + Folders(idx, 0).Height + SB + CH + MH + OY + BelowSpace
  1323.   FolderTabs(idx).Parent.Width = Folders(idx, 0).Width + FolderBorder(idx).Width + SB + OX + leftinit * 2
  1324.   
  1325.   DrawTabs idx
  1326.  
  1327.   SetScaleMode idx, oldscalemode
  1328. End Sub
  1329.  
  1330. ' Calculate the row of a particular tab
  1331. Private Function VerTabPos (idx As Integer, TN As Integer) As Integer
  1332. Dim i As Integer
  1333. Dim J As Integer
  1334.  
  1335.   i = TN \ VisibleTabs(idx) + 1
  1336.   J = CurrentTab(idx) \ VisibleTabs(idx) + 1
  1337.   If i >= J Then
  1338.     VerTabPos = i - J + 1
  1339.   ElseIf J > i Then
  1340.     VerTabPos = NumRows(idx) - (J - i) + 1
  1341.   End If
  1342.  
  1343. End Function
  1344.  
  1345.