home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD1259312112000.psc / modTab.bas < prev    next >
Encoding:
BASIC Source File  |  2000-12-11  |  7.4 KB  |  211 lines

  1. Attribute VB_Name = "modTab"
  2. Option Explicit
  3.  
  4. Private Const mcsModuleName As String = "modTab"
  5. Private Const mcsContainerNotValidError = "the Container object (usually picture box and/or frame) " & "passed to the function listed in 'source' below, must be a control array, " & "and the indexe numbers should correspond to the tab numbers. " & vbCrLf & "(Note: since the tabstrip's index must " & "start at 1, the container control array should start with an index of 1 not 0)"
  6.  
  7.  
  8. '__________________________________________________
  9. ' Scope  : Public
  10. ' Type   : Sub
  11. ' Name   : CreateTabsFromContainerP
  12. ' Params : 
  13. '          oTabStrip As TabStrip
  14. '          ocontainer As Object
  15. ' Returns: Nothing
  16. ' Desc   : The Sub uses parameters oTabStrip As TabStrip and ocontainer As Object for CreateTabsFromContainerP and returns Nothing.
  17. '__________________________________________________
  18. ' History
  19. ' CDK: 20001112: Added Error Trapping & Comments using
  20. '        Auto-Code Commenter
  21. '__________________________________________________
  22. Public Sub CreateTabsFromContainerP(oTabStrip As TabStrip, ocontainer As Object)
  23.  
  24.     
  25.     Const csProcName As String = "HandleTabStripP"
  26.     On Error GoTo PROC_ERR
  27.     
  28.     Dim vitem As Variant
  29.     
  30.     oTabStrip.Tabs.Clear
  31.     'add the tabs according to the 'tag' property of the container control array
  32.     For Each vitem In ocontainer
  33.         oTabStrip.Tabs.Add vitem.Index, , vitem.Tag
  34.     Next
  35.     
  36.     ''if there is only one tab, hide the tab form
  37.     'If oTabStrip.Tabs.Count = 1 Then
  38.     '    oTabStrip.Visible = False
  39.     'End If
  40.     
  41. PROC_EXIT:
  42.     GoSub Proc_Cleanup
  43.     Exit Sub
  44.     
  45. PROC_ERR:
  46.     Dim lErrNum As Long, sErrSrc As String, sErrDesc As String
  47.     sErrSrc = mcsModuleName & "_" & csProcName
  48.     lErrNum = Err.Number
  49.     If lErrNum = 343 Or lErrNum = 35600 Or lErrNum = 438 Then
  50.         'the item is not a control array, so raise the appropriate error
  51.         sErrDesc = mcsContainerNotValidError
  52.     Else
  53.         sErrDesc = Err.Description
  54.     End If
  55.     Resume Proc_Err_Continue
  56.     Resume
  57.     
  58. Proc_Err_Continue:
  59.     GoSub Proc_Cleanup
  60.     
  61.     Err.Raise lErrNum, sErrSrc, sErrDesc
  62.     Exit Sub
  63.     Resume
  64.     
  65. Proc_Cleanup:
  66.     On Error Resume Next
  67.     On Error GoTo 0
  68.     Return
  69.  
  70. End Sub
  71.  
  72.  
  73. '__________________________________________________
  74. ' Scope  : Public
  75. ' Type   : Sub
  76. ' Name   : HandleTabStripP
  77. ' Params : 
  78. '          oTabStrip As TabStrip
  79. '          ocontainer As Object
  80. '          Optional fMoveToFront As Boolean = False
  81. '          Optional vOriginX As Variant
  82. '          Optional vOriginY As Variant
  83. ' Returns: Nothing
  84. ' Desc   : The Sub uses parameters oTabStrip As TabStrip, ocontainer As Object, Optional fMoveToFront As Boolean = False, Optional vOriginX As Variant and Optional vOriginY As Variant for HandleTabStripP and returns Nothing.
  85. '__________________________________________________
  86. ' History
  87. ' CDK: 20001112: Added Error Trapping & Comments using
  88. '        Auto-Code Commenter
  89. '__________________________________________________
  90. Public Sub HandleTabStripP(oTabStrip As TabStrip, ocontainer As Object, Optional fMoveToFront As Boolean = False, Optional vOriginX As Variant, Optional vOriginY As Variant)
  91.  
  92.     ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  93.     'Comments   : The following function will handle associating a tab
  94.     '               strip's click with the positioning of the appropriate
  95.     '               a frame control array item or picture box control array item
  96.     '             This function assumes that the index of each container item
  97.     '               is the same as it's associated tab
  98.     '               (ie - the tabstrips 1st tab has index of 1.  when this is clicked
  99.     '               the container with the index of 1 will be displayed)
  100.     '             Note: the control array must start at 1 not at 0
  101.     '               since the tab's index must start at 1)
  102.     '             This function COULD be used in conjunction with
  103.     '               the CreateTabsFromContainerP function since it
  104.     '               populates the tabs with the container's index property
  105.     'Parameters : oTabStrip - the tabstrip on that will control
  106.     '               the oContainer
  107.     '             oContainer - the container (usually a pic box or frame)
  108.     '               that will be switched according to the click of oTabStrip
  109.     ' Returns   : Nothing - raises error if parameters are not appropriate
  110.     ' Source    : Charlie Kirkwood
  111.     ' Update    :
  112.     ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  113.  
  114.     Const csProcName As String = "HandleTabStripP"
  115.     Dim vitem As Variant
  116.     Dim vItemCount As Long
  117.     
  118.     On Error GoTo PROC_ERR
  119.     
  120.     For Each vitem In ocontainer
  121.         vItemCount = vItemCount + 1
  122.     Next
  123.     
  124.     'check to see if the frame is a control array, if we test the index property and it errors to 343
  125.     '   then it's not a control array, the error handler will take care of it
  126.     For Each vitem In ocontainer
  127.     
  128.         If vitem.Index = oTabStrip.SelectedItem.Index Then
  129.             
  130.             'default will be a little past the bottom of the the tabstrip's tabs, but user may
  131.             '   specify origin for pic box
  132.             If IsMissing(vOriginX) Then
  133.                 vOriginX = 120
  134.             End If
  135.             
  136.             If IsMissing(vOriginY) Then
  137.                 'if the borderstyle of the container is
  138.                 '   visible, then account for it,
  139.                 '   otherwise push it against the edge
  140.                 If vitem.BorderStyle = 0 Then
  141.                     If vItemCount = 1 Then
  142.                         vOriginY = 360
  143.                     Else
  144.                         vOriginY = 420
  145.                     End If
  146.                 Else
  147.                     vOriginY = 360
  148.                 End If
  149.             End If
  150.             
  151.             vitem.Move oTabStrip.Left + vOriginX, oTabStrip.Top + vOriginY
  152.             
  153.                         
  154.             If fMoveToFront Then
  155.                 vitem.ZOrder 0
  156.                 vitem.Enabled = True
  157.             End If
  158.             
  159.         Else
  160.         
  161.             'move the container out of view on the form
  162.             vitem.Move -25000, -25000
  163.             vitem.Enabled = False
  164.         
  165.         End If
  166.     
  167.     Next
  168.     
  169. '    lLowerBound = ocontainer.lbound
  170. '    lUpperBound = ocontainer.ubound
  171. '
  172. '    For lCounter = lLowerBound To lUpperBound
  173. '        If lCounter = oTabStrip.SelectedItem.Index Then
  174. '            ocontainer(lCounter).Move oTabStrip.Left + 120, oTabStrip.Top + 480
  175. '        Else
  176. '            'move the container out of view on the form
  177. '            ocontainer(lCounter).Move -25000, -25000
  178. '        End If
  179. '    Next
  180.     
  181. PROC_EXIT:
  182.     GoSub Proc_Cleanup
  183.     Exit Sub
  184.     
  185. PROC_ERR:
  186.     Dim lErrNum As Long, sErrSrc As String, sErrDesc As String
  187.     sErrSrc = mcsModuleName & "_" & csProcName
  188.     If Err.Number = 343 Then
  189.         'the item is not a control array, so raise the appropriate error
  190.         lErrNum = 343
  191.         sErrDesc = mcsContainerNotValidError
  192.     Else
  193.         lErrNum = Err.Number
  194.         sErrDesc = Err.Description
  195.     End If
  196.     Resume Proc_Err_Continue
  197.     
  198. Proc_Err_Continue:
  199.     GoSub Proc_Cleanup
  200.     Err.Raise lErrNum, sErrSrc, sErrDesc
  201.     Exit Sub
  202.     
  203. Proc_Cleanup:
  204.     On Error Resume Next
  205.     On Error GoTo 0
  206.     Return
  207.  
  208. End Sub
  209.  
  210.  
  211.