PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Infinite Progress Bar
Infinite Progress Bar
Débuté par John Fligg, 17 aoû. 2017 11:58 - 24 réponses
Posté le 17 août 2017 - 11:58
Hi, I am having trouble implementing an Infinite Progress Bar.

I am trying ThreadExecute to open a Sister Window but having no success. Basically I need to find out how to make the progress bar animate.

Does anyone have a small app demonstrating how to do this or explain the logic of what needs to be done.

I do wonder if what I am actually trying to do is complicating this.

In my Login Window based on a response I then want to display a progress bar while a daisy chain of procedures run (including accessing a remote server) and show the progress bar animated while all this happens in the background.

I hope this makes sense. Thanks so much in anticipation.

John
Posté le 17 août 2017 - 12:49
Hi John,

You can use an image with animated gif to show that someting is happening.
Additionally you can also use some progress in a progressbar.
Set the maximum value to the number of procedures that need to be done an increment the progressbar when a procedure has finished.
On top of that you can also display "connecting to server", "loading data" etc.

Kind regards,
Piet
Posté le 17 août 2017 - 13:08
Thank you Piet. Do you need to run the procedures in another thread (ThreadExecute)?

Thx
Posté le 18 août 2017 - 14:09
Hi John,

As the user needs to wait for the login process to finish anyway, there's no need for another thread.
Don't forget to do a multitaskredraw to update the controls:
img_Wait..visible=true //show your animated gif. stc_Message..visible=true stc_Message="Connecting to the server" multitaskredraw() Procedure1() PROGBAR_ProgBar1 = 1 stc_Message="Loading data" multitaskredraw() Procedure2() PROGBAR_ProgBar1 = 2 multitaskredraw() etc. img_Wait..visible=false You could also show these controls and do the procedures in a small child window. Then you don't need to do the visible/invisible stuff.

Kind regards,
Piet
Posté le 18 août 2017 - 14:14
Thank you Piet. I have been trying all sorts.

I have actually got the control working and animated but once the procedure has finished I cannot find out how to return to the MainThread. There is a command to stop the secondary thread but it is not available in Android. That is so frustrating.

So I will try your method Piet but I do need to implement the animated control at some stage elsewhere.

Many thanks

John
Posté le 18 août 2017 - 14:43
I do not believe this.

Multitaskredraw is not available in Android.

John
Posté le 18 août 2017 - 15:49
Exceedingly annoying. But even so I can work round it but the animated image does not animate. Grrrr.

I have set the Properties and also made sure it is animated using code.

I think I might just give up on this one!
Posté le 18 août 2017 - 16:00
Hi John,

Sorry to hear that, I thought you were using Windev.

Kind regards,
Piet
Posté le 18 août 2017 - 16:31
In windev mobile you can't use gifs as animated images, you need svg images, if you want to play a gif you can use an HTML control and write html code as if you were doing an HTML page with only the img src tag. Other workaround is to use the hourglass, it is an infinite progress bar and you can write the thing you want it to say. For example:

NextTitle("Loading...")
Hourglass(True)
FOR EACH USER
Multitask(-1)
//Some process
END
Hourglass(False)
NextTitle("")

If you don't write the multitask the animation won't move. Hope this helps, if you are using HTTPRequest to download things there's another way you can do it with a progressbar, in that case you could use HTTPProgressBar before HTTPDestination.
Posté le 18 août 2017 - 18:36
Thank you Luis I was not aware they had to be SVG, The odd thing is that I used the animated GIF's provided by PCSoft.

John
Posté le 18 août 2017 - 20:42
Hi,

I have a similar issue that I have not been able to solve.

When I am running long processes I call a small pop up window using

opensister(win_processing)

and then close that window when the process is complete.

I would like an infinite progress bar to display and re-animate in the "win_processing" window but have not been able to get to work.

I'm using windev 20.

Is this possible? Tips?

Thanks!

Steve
Posté le 18 août 2017 - 20:46
I guess the problem is just in Mobile,'cuz the animated gifs do work in other platforms, I notice this when upgrading to version 22 where a new control of animated images was introduced, I needed to put some gifs in my app, but they didn't move, when I selected a predefined animated image I notice that those were svg instead of gifs.

And as for Steve you could use the hourglass function and before calling the Hourglass use multitaskredraw and then display a gif, haven't done this but it may work, also tried to do the same thing you are doing with a small window and didn't manage to make it work
Posté le 19 août 2017 - 11:06
Well I have managed to move forward slightly.

It seems that the animated GIF's DO work despite being a GIF. So the SVG format is a red herring.

If you place an animated control on the page it works. The problem is this:

If you make the control visible or not or try putting it in another window/plane the animation stops.

Am going to explore putting the control off the screen then moving it on using X/Y to see if that works.
Posté le 22 août 2017 - 08:11
Hi John

Do let us know if you ever get this resolved.

Cheers
André
Posté le 22 août 2017 - 09:45
I've given up Andre. I know it is something to do with running the procedures on another thread, which I have done. The Main thread is supposed to control the animation. But it just does not work, as simple as that.
Posté le 23 août 2017 - 19:36
Just use the Hourglass function, it is an infinite progress bar
Posté le 24 août 2017 - 09:57
It is not available in iOS. Apple do not like anything like this being used.
Posté le 24 août 2017 - 16:54
I'm using the hourglass in iOS
[attachment 2431 Captura-compressor.png]
Posté le 25 août 2017 - 09:53
Hmm must have been mistaken. Ah now I remember. Yes it Is available but at the time I was looking at pubishing to the Store. Then I heard that an Hourglass is rejected by Apple when having your app scrutinized. However I do not use the Stores so maybe I will look at this again. Thx.
Posté le 25 août 2017 - 13:37
Hi John

I am using the hourglass and it does work. But I also always display a message so that the user knows what is happening. If software on hardware does not always tell warmware what is happening they tend to think the thing is hanging and it is in an infinite loop.

But best keep way from the progress bars. I also never got them to work.

Cheers
André
Posté le 25 août 2017 - 15:04
What Msg command are you using out of curiosity? Obviously if you use Info() then the user has to press a key. So it has to be something not requiring a response. Thx.
Posté le 25 août 2017 - 23:30
For the message being displayed while the hourglass is showing you can use NextTitle("Text you want to show") and then call Hourglass(True)
Posté le 26 août 2017 - 07:50
John - I am simply hiding and making visible a string that has a good background colour. It is that simple. I place it on plane 0 - together with other bits and bobs. It has proved to be quite effective. Humans no longer wonder what is going on.

I have not tried Luis's suggestion.

André
Posté le 26 août 2017 - 08:51
Steve,

I have found that an animated gif will not animate in the sister window unless you call it in a seperate thread. Then run your processess. Then close the sister window. This is what I have done.
Posté le 26 août 2017 - 11:23
Thx. NextTitle does not seem to work. And displaying a hidden string doesn't either.

I now think this is something to do with timing. After I click an OK button to start of the process/es nothing seems to work until everything has finished.

In other words, for Android only, once the button has been pressed nothing will redisplay until the other processes complete. Not even changing a plane of making a control visible.

Hourglass does work but NextTitle does not do anything.

Very very frustrating indeed. But Windows and iOS are fine it's just Android which seems to be the issue.