06-08-2009 12:01 PM
I am using a Message box (MsgBoxDisp) to present to the user the filename and row # within that file so that progress can be monitored.
The msgBoxDisp command is inside a DoWhile loop. Loop count could range from 10 to 10000 depending on the data.
My problem is the screen redraw. The window blinks to the point of being unreadable. In fact, it appears to be bouncing back and forth between the dialog box (updated text each loop) and the main Diadem window.
Is there any way to stop this? I tried just putting the text into the Statusbar, but it was blinking and unreadable there too!
Any ideas would be appreciated. Here is the code
Do While ChannelIndex <= ChannelSize
'Inform user of progress
StatusMsg = "Now working with data file " & FileIndex & " of " & _
FileCount & ":" & Chr(13) & NameSplit(CurrentFile,"N") & Chr(13) & _
"Completed " & StopCount & " Cycles"
Call MsgBoxDisp (StatusMsg, "MB_NoButton", "MsgTypeNote", _
0, 0, 1,0)
.
.
.
.Loop
06-08-2009 03:16 PM
Hello Jeff!
It is not possible to achive what you want - and IMHO users expect - with MsgBoxDisp.
There a two possible solutions:
Matthias
Matthias Alleweldt Project Engineer / Projektingenieur | Twigeater? |
06-09-2009 08:06 AM
I was afraid of that, Mathias. Thanx for confirming.
Can you guess why the same blinking occurs when I try to update the Status bar instead? Sounds like the smart thing to do is just put up the hourglass and hope the system doesn't lock up.
06-09-2009 08:57 AM
Hi Jeff,
The simplest workaround would be to limit the maximum number of MsgBox updates to something like 20 or 50. You would then determine in each loop if the current loop was one that gets to write to the MsgBox, such that you only updated the MsgBox every 5 loops or every 10 loops or so. The user doesn't really need to see 1000 updates to the MsgBox and may have a hard time reading the numbers/text flying by even in the absence of flickering. Depending on what you're doing in the loop, a DIAdem progress bar is another option.
'The progress bar is only updated 100 times
Loops = 150
CountStep = 5 ' %
NextCount = CountStep
Call LoopInit()'Opens session to Progress bar
For i = 1 To Loops' Start of your code (simulated here)
StartTime = Timer
Do
EndTime = Timer
Loop Until EndTime-StartTime > 0.05
' End of your code (simulated here)
LoopCount = Fix(100*i/Loops)IF LoopCount >= NextCount THEN
Call LoopInc(LoopCount) ' Updates the Progress bar with value between 0 and 100
NextCount = NextCount + CountStep
End IfNext
Call LoopDeInit 'Clear the Progress Bar
Brad Turpin
DIAdem Product Support Engineer
National Instruments
06-09-2009 09:15 AM
Thanks, Brad.
I tried the status bar...didn't work so well. Its light gray and barely shows up...plus it changes in between steps, looks confusing.
The limiting to every 100 loop is a good compromise...good idea.
Jeff