I display a report in a listbox that sometimes takes 10-20 seconds to populate. I have been trying to use an indeterminate progress bar to show that it is working. If I make the progress bar visible in the method that runs the report, the progress bar does not show until the screen updates with the completed report. When I make it visible then start a one-time timer that calls the method that generates the report, the progress bar becomes visible, but it doesn’t start moving until the report is complete. I have tried with the progress bar on the report window and in a separate window that just has a progress bar on it. I have even tried setting a Maximum value and incrementing the value with a timer every 200 ms. That also shows the progress bar, but it does not start to fill until the report shows. I’m starting to think about popping up a window that simply says “Please wait…”
Xojo 2017r1
Win 10 Pro
here is what I use … its a custom subclass of a canvas
PAINT EVENT
#pragma Unused areas
Dim w As Integer
Dim h As Integer
g.TextFont="System"
g.TextSize=18
w=g.StringWidth(zMsg)+8
Me.height=g.stringheight(zMsg,w)+8
Me.Width=w+Me.height
me.left=(winMAIN.width-me.width)\\2
me.top=(winMAIN.height-me.height)\\3
//
h=g.height
w=g.width
g.ForeColor=&c3b3b3b
g.FillRoundRect 0,0,w,h,h,h
g.ForeColor=&caaaaaa
g.DrawRoundRect 0,0,w,h,h,h
g.ForeColor=&cfefefe
w=(g.width-g.StringWidth(zMsg))\\2
g.DrawString zMsg,w,2+g.TextAscent
Properties
Public Property message as string
Get
return zMsg
End Get
Set
zMsg=Trim(value)
If winMAIN.Timer_Message=Nil Then Return
If zMsg="" Then
Self.Visible=False
winMAIN.timer_message.mode=timer.ModeOff
Else
Self.Visible=True
Self.Invalidate
End If
End Set
End Property
Public Property messageFADE as string
Get
return zMsg
End Get
Set
zMsg=Trim(value)
If winMAIN.Timer_Message=Nil Then Return
If zMsg="" Then
Self.Visible=False
winMAIN.timer_message.mode=timer.ModeOff
Else
Self.Visible=True
Self.Invalidate
//
winMAIN.timer_message.mode=timer.ModeSingle
End If
End Set
End Property
Private Property zMsg as string
NOTE : requires a TIMER (winMAIN.timer) in the code above
setting the MESSAGE property will display the message until you set it to “”
setting the MESSAGEFADE property will display it for the length of the time, and it will vanish
[quote=324566:@Dean Davidge]I display a report in a listbox that sometimes takes 10-20 seconds to populate. I have been trying to use an indeterminate progress bar to show that it is working. If I make the progress bar visible in the method that runs the report, the progress bar does not show until the screen updates with the completed report. When I make it visible then start a one-time timer that calls the method that generates the report, the progress bar becomes visible, but it doesn’t start moving until the report is complete. I have tried with the progress bar on the report window and in a separate window that just has a progress bar on it. I have even tried setting a Maximum value and incrementing the value with a timer every 200 ms. That also shows the progress bar, but it does not start to fill until the report shows. I’m starting to think about popping up a window that simply says “Please wait…”
Xojo 2017r1
Win 10 Pro[/quote]
It sounds like your problem is fairly simple, while your application is generating/printing the report; it can’t do anything else. To get around this you can either.
- Do what you suggest; create a static window.
- Use a thread for generating/printing (but see the recent thread in the forum on crashes due to this).
- Create a helper application to do the report generation and printing for you, leaving the main application free to display a progress bar.
- DIRTY OPTION; use app.doEvents in your routine to free up some processor time so that it can update the GUI while it’s busy.
Since I am displaying the report on the screen, the thread won’t work without using a lot of memory. Another option would be to generate enough of the report to fill the screen, display it, then generate the rest of the report.
Thanks for your suggestions.
A couple of tips…
- Don’t populate the listbox cell by cell, use Addrow(array())
- Do you request, then add all the rows in one go.
- Hide the listbox, populate, then make visible.
Number 1 has by far the most affect on the speed.
Lee