
Refreshing a process intensive form and updating after lost focus
Hi All,
I will try to explain what I mean,
I have a form that has code in it that is pretty intensive.
e.g.
FileOpen(hFile, sPath, OpenMode.Binary, OpenAccess.Read,
OpenShare.LockReadWrite)
FileGet(hFile, sStream)
StatusBar.Text = "Processing user list : "
StatusBar.Refresh()
OkCancelPanel.Visible = False
IconProgress.Visible = True
Progress.Maximum = Len(sStream)
' StatusBar.Width = Me.Width - 60
Progress.Step = 1
Progress.Visible = True
Pic1.Visible = True
Pic1.Refresh()
dtTime = Now
While Len(sStream) > 0
Me.Refresh()
ShowIcons()
dLen = sStream.IndexOf(Chr(13) & Chr(10))
If dLen <= 0 Then
dLen = 0
End If
sLine = sStream.Substring(0, dLen)
sStream = sStream.Substring(dLen + 2)
Progress.Value = Progress.Maximum - Len(sStream)
alIni.Add(sLine)
End While
The problem is that when you click on to another window and then click back
the form does not repaint the contents.
In the task manager of Windows XP the program shows that it is not
responding although I know it is processing.
How do I get this code to relinquish control to the OS momentarily so that
other timer events and the repaint of the form can get a bit of the
processing power.
e.g.
FileOpen(hFile, sPath, OpenMode.Binary, OpenAccess.Read,
OpenShare.LockReadWrite)
FileGet(hFile, sStream)
StatusBar.Text = "Processing user list : "
StatusBar.Refresh()
OkCancelPanel.Visible = False
IconProgress.Visible = True
Progress.Maximum = Len(sStream)
' StatusBar.Width = Me.Width - 60
Progress.Step = 1
Progress.Visible = True
Pic1.Visible = True
Pic1.Refresh()
dtTime = Now
While Len(sStream) > 0
APPLICATION.IDLE()
ShowIcons()
dLen = sStream.IndexOf(Chr(13) & Chr(10))
If dLen <= 0 Then
dLen = 0
End If
sLine = sStream.Substring(0, dLen)
sStream = sStream.Substring(dLen + 2)
Progress.Value = Progress.Maximum - Len(sStream)
alIni.Add(sLine)
End While
Thank You
Mark Hollander