home *** CD-ROM | disk | FTP | other *** search
/ Troubleshooting Netware Systems / CSTRIAL0196.BIN / attach / msj / v10n10 / vb40.exe / WCIMR.EXE / WCTHRDS.BAS < prev   
BASIC Source File  |  1995-10-01  |  6KB  |  222 lines

  1. Attribute VB_Name = "WCIMThreads"
  2. Sub FillThreadList(FoldPath As String)
  3.  
  4. ' Fills the thread list based on the current folder
  5. ' This is called when the user double-clicks on the
  6. ' Folders tree
  7.  
  8.     Dim CH As CommonHeader
  9.     Dim CP As CommonPStrings
  10.     Dim FTH As ForumThdHeader
  11.     Dim SLen As Byte
  12.     Dim FNum As Integer
  13.     Dim PicNum As Variant
  14.  
  15.     gNumThreads = 0
  16.     ReDim Preserve gThreadList(20)
  17.  
  18. On Error Resume Next
  19.     Set sel = MainFrm.tvwFolders.SelectedItem
  20.     Entry$ = sel.Tag
  21.  
  22.     If Err.Number <> 0 Then Exit Sub ' no sel item
  23.     
  24.     MainFrm.lvwThreads.ListItems.Clear
  25.  
  26.     SLen = 1
  27.  
  28.     If (FoldPath = "BASKET.IN") Or (FoldPath = "BASKET.OUT") Then
  29.         MyFile = Dir(WCimDir & "\" & FoldPath & "\*.*")
  30.     Else
  31.         MyFile = Dir(WCimDir & "\CABINET\" & FoldPath & "\*.*")
  32.     End If
  33.     
  34.     Do While MyFile <> ""
  35.         gNumThreads = gNumThreads + 1
  36.  
  37.         If (gNumThreads > UBound(gThreadList)) Then
  38.             ReDim Preserve gThreadList(10 + UBound(gThreadList))
  39.         End If
  40.  
  41.         If (FoldPath = "BASKET.IN") Or (FoldPath = "BASKET.OUT") Then
  42.             FName = WCimDir & "\" & FoldPath & "\" & MyFile
  43.         Else
  44.             FName = WCimDir & "\CABINET\" & FoldPath & "\" & MyFile
  45.         End If
  46.         
  47.         gThreadList(gNumThreads).FName = FName
  48.         gThreadList(gNumThreads).ShortFName = MyFile
  49.  
  50.         FNum = FreeFile
  51.         Open FName For Binary Access Read Lock Read As #FNum
  52.  
  53.         RC = GetCommonHeader(FNum, gThreadList(gNumThreads).ComHdr, gThreadList(gNumThreads).ComPStr)
  54.  
  55.         If (RC = False) Then
  56.             'LstThreads.AddItem (MyFile)
  57.  
  58.             Set X = MainFrm.lvwThreads.ListItems.Add(, , MyFile)
  59.             X.Tag = sel.Tag
  60.             
  61.             ' Set the timestamp field
  62.             X.SubItems(1) = TSToDate(gThreadList(gNumThreads).ComHdr.Created)
  63.             
  64.             X.SubItems(2) = "Bad file type"
  65.             X.SubItems(3) = MyFile
  66.             X.SubItems(4) = gNumThreads
  67.  
  68.  
  69.             GoTo ReadThdBail
  70.         End If
  71.  
  72.         Get #FNum, , gThreadList(gNumThreads).Header
  73.  
  74.         Set X = MainFrm.lvwThreads.ListItems.Add(, , gThreadList(gNumThreads).ComPStr.Subject.SData)
  75.         X.Tag = MyFile
  76.         X.SubItems(3) = MyFile
  77.         X.SubItems(4) = gNumThreads
  78.  
  79.         ' Set the timestamp field
  80.         X.SubItems(1) = TSToDate(gThreadList(gNumThreads).ComHdr.Created)
  81.  
  82.         Select Case gThreadList(gNumThreads).ComHdr.RecType
  83.         
  84.         Case MT_UNDEF
  85.             PicNum = picUnknown
  86.             X.SubItems(2) = "Undefined file type"
  87.         Case MT_EMAIL
  88.             PicNum = picMail
  89.             X.SubItems(2) = "E-Mail message"
  90.         Case MT_FORMSG
  91.             PicNum = picForum
  92.             X.SubItems(2) = "Forum message"
  93.         Case MT_FORTHD
  94.             PicNum = picThread
  95.             X.SubItems(2) = "Forum thread"
  96.         Case MT_IPLEX
  97.             PicNum = picUnknown
  98.             X.SubItems(2) = "Infoplex message"
  99.         Case MT_DISP
  100.             PicNum = picMail
  101.             X.SubItems(2) = "Display message"
  102.         Case MT_ENS
  103.             PicNum = picNews
  104.             X.SubItems(2) = "News item"
  105.         Case Else
  106.             PicNum = picUnknown
  107.             X.SubItems(2) = "Unknown file type"
  108.         End Select
  109.  
  110. ReadThdBail:
  111.         Close #FNum
  112.         On Error Resume Next
  113.         MyFile = Dir
  114.         If Err.Number <> 0 Then Exit Sub
  115.         DoEvents
  116.     Loop
  117.  
  118. End Sub
  119.  
  120. Sub AddThreadToList(N As Integer)
  121.  
  122. ' Adds a thread (by number) to the list of found threads.
  123. ' This is called when the user invokes a search.
  124.  
  125. On Error Resume Next
  126.  
  127.         Set X = MainFrm.lvwThreads.ListItems.Add(, , gThreadList(N).ComPStr.Subject.SData)
  128.         X.Tag = gThreadList(N).ShortFName
  129.         X.SubItems(3) = gThreadList(N).ShortFName
  130.         X.SubItems(4) = N
  131.  
  132.         ' Set the timestamp field
  133.         X.SubItems(1) = TSToDate(gThreadList(N).ComHdr.Created)
  134.  
  135.         Select Case gThreadList(N).ComHdr.RecType
  136.  
  137.         Case MT_UNDEF
  138.             PicNum = picUnknown
  139.             X.SubItems(2) = "Undefined file type"
  140.         Case MT_EMAIL
  141.             PicNum = picMail
  142.             X.SubItems(2) = "E-Mail message"
  143.         Case MT_FORMSG
  144.             PicNum = picForum
  145.             X.SubItems(2) = "Forum message"
  146.         Case MT_FORTHD
  147.             PicNum = picThread
  148.             X.SubItems(2) = "Forum thread"
  149.         Case MT_IPLEX
  150.             PicNum = picUnknown
  151.             X.SubItems(2) = "Infoplex message"
  152.         Case MT_DISP
  153.             PicNum = picMail
  154.             X.SubItems(2) = "Display message"
  155.         Case MT_ENS
  156.             PicNum = picNews
  157.             X.SubItems(2) = "News item"
  158.         Case Else
  159.             PicNum = picUnknown
  160.             X.SubItems(2) = "Unknown file type"
  161.         End Select
  162.  
  163. ReadThdBail:
  164.         If Err.Number <> 0 Then Exit Sub
  165.         DoEvents
  166.  
  167. End Sub
  168.  
  169. Sub ResetThreadList()
  170.  
  171. ' Refills the thread list after a search is cancelled
  172. ' This procedure is similar to FillThreadList, except that
  173. ' the files are not re-read.
  174.  
  175. On Error Resume Next
  176.     For N = 1 To gNumThreads
  177.         Set X = MainFrm.lvwThreads.ListItems.Add(, , gThreadList(N).ComPStr.Subject.SData)
  178.         X.Tag = gThreadList(N).ShortFName
  179.         X.SubItems(3) = gThreadList(N).ShortFName
  180.         X.SubItems(4) = N
  181.  
  182.         ' Set the timestamp field
  183.         X.SubItems(1) = TSToDate(gThreadList(N).ComHdr.Created)
  184.  
  185.         Select Case gThreadList(N).ComHdr.RecType
  186.  
  187.         Case MT_UNDEF
  188.             PicNum = picUnknown
  189.             X.SubItems(2) = "Undefined file type"
  190.         Case MT_EMAIL
  191.             PicNum = picMail
  192.             X.SubItems(2) = "E-Mail message"
  193.         Case MT_FORMSG
  194.             PicNum = picForum
  195.             X.SubItems(2) = "Forum message"
  196.         Case MT_FORTHD
  197.             PicNum = picThread
  198.             X.SubItems(2) = "Forum thread"
  199.         Case MT_IPLEX
  200.             PicNum = picUnknown
  201.             X.SubItems(2) = "Infoplex message"
  202.         Case MT_DISP
  203.             PicNum = picMail
  204.             X.SubItems(2) = "Display message"
  205.         Case MT_ENS
  206.             PicNum = picNews
  207.             X.SubItems(2) = "News item"
  208.         Case Else
  209.             PicNum = picUnknown
  210.             X.SubItems(2) = "Unknown file type"
  211.         End Select
  212.     Next N
  213.     
  214. ReadThdBail:
  215.         If Err.Number <> 0 Then Exit Sub
  216.         DoEvents
  217.  
  218. End Sub
  219.  
  220.  
  221.  
  222.