The IT department has been asked to develop a program to assist in
archiving the older documents. We have a stored procedure that returns
the docket numbers to the cases that may have documents which are
eligible to be archived. Based on the docket number the path to the
directory where the documents are stored can be calculated.
I developed several classes that takes the list of docket numbers and
checks the file sizes of each document and divides the directories and
documents into CD volumes. It first creates a list of CD volumes and
which directories and transcripts are in each volume. It then
populates a treeview with the information.
As the program does its job it uses a progressbar to let the user know
how far along it is and after fully populating a CD volume node with
the associated directories and transcripts in those directories is
refreshes. The effect is that the user sees each CD node pop into view
when it is fully populated.
The problem is, however, that sometimes the progressbar and the
treeview stop refreshing. This gives the appearance that the program
has hung. But in the end the treeview and progress bar suddenly
refresh and all of the CD volumes will pop into view. There is no way
for the code that increments the progressbar or the code that updates
the treeview can be skipped and have the nodes still be populated. Can
anyone tell me what may be going on? Below is the sub where the nodes
are being poplulated:
Private Sub DisplayVolumes()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim v As Volume
Dim d As Directory
Dim t As Transcript
InitImageList()
vL = aM.GetVolumes()
For i = 1 To vL.Count
v = vL(i)
ProgressBar1.Maximum = v.Count
StatusBar1.Text = "Populating Nodes for CD-" & i
VolumeTreeView.Nodes.Add(New TreeNode(v.Name, 1, 2))
Dim n As TreeNode = VolumeTreeView.Nodes(i - 1)
For j = 1 To v.Count
ProgressBar1.Value = j
d = v.GetDirectory(j)
n.Nodes.Add(New TreeNode(d.Name, 3, 4))
Dim m As TreeNode = n.Nodes(j - 1)
For k = 1 To d.Count
t = d.GetTranscript(k)
m.Nodes.Add(New TreeNode(t.Name, 5, 5))
Next
Next
VolumeTreeView.Refresh()
Next
End Sub
This an annoying "feature" in WinXP. See 3rd paragraph:
Work-around: In addition to calling progressbar1.refresh, call PeekMessage
API function:
Public Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" _
(ByRef lpMsg As MSG, ByVal hwnd As IntPtr, _
ByVal wMsgFilterMin As Integer, ByVal wMsgFilterMax As Integer, _
ByVal wRemoveMsg As Integer) As Boolean
'...
PeekMessage(Nothing, Nothing, 0, 0, 0)
The designers probably thought that, if IN-put is not processed, there is no
OUT-put, too. Obviously this is wrong.
Armin
Thanks.
Sorry, forgot the declaration:
<StructLayout(LayoutKind.Sequential)> _
Public Structure Point
Public x As Integer
Public y As Integer
End Structure
<StructLayout(LayoutKind.Sequential)> _
Public Structure MSG
Public hwnd As IntPtr
Public message As Integer
Public wParam As IntPtr
Public lParam As IntPtr
Public time As Integer
Public point As Point
End Structure
Armin