|
|
Home » Community » Newbie corner » ProgressIndicator issue
ProgressIndicator issue [message #53223] |
Tue, 24 March 2020 11:21  |
idkfa46
Messages: 155 Registered: December 2011
|
Experienced Member |
|
|
Hallo guys,
I have a problem with my ProgressIndicator included in StatusBar.
My ProgressIndicator do not show the indicator increase till the end of the cicle (where displaying 100%)... it seems like the statusbar is not refreshed everytime, isn't it?
If I add a progress too, it works perfectly! Why?
How can I fix it removing the progress?
Here is a little example:
class test : public WithtestLayout<TopWindow> {
StatusBar status;
ProgressIndicator pi;
public:
void load();
typedef test CLASSNAME;
test();
};
test::test()
{
CtrlLayout(*this, "Window title");
AddFrame(status);
pi.Hide();
pi.Percent();
status.Add(pi.RightPos(5, 200).TopPos(2, 15));
goBtn <<= THISBACK(load);
}
void test::load()
{
Progress p;
p.Create();
pi.Show();
pi.Set(0,1000000);
for(int i = 0; i <=1000000; i++)
{
pi.Set(i);
p.SetPos(i);
}
p.Close();
pi.Close();
}
GUI_APP_MAIN
{
test().Run();
}
|
|
|
|
|
|
Re: ProgressIndicator issue [message #53228 is a reply to message #53223] |
Tue, 24 March 2020 14:21   |
 |
Xemuth
Messages: 387 Registered: August 2018 Location: France
|
Senior Member |
|
|
Here we go, this example show you how I deal with Progress Indicator, may there is another way of doing it (without thread maybe ?) But I don't know it.
May more experienced member wich know how to deal with it in a different way can share with us.
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
class testIndicator : public TopWindow {
private:
ProgressIndicator progress;
Button button;
public:
typedef testIndicator CLASSNAME;
void myCallBack(){
Thread().Run([&](){
GuiLock __; //Since we are in thread we cant modify GUI, Except if we create a struct Name GuiLock wich will give ctrl of GUI to this thread
button.Disable(); //Action on GUI
GuiUnlock _; // Release the GUI Ctrl (if not done then the gui can freze because main thread wich processe Mouse/key Ctrl and other GUI things is stuck since it don't have Ctrl of GUI anymore)
for(int e = 0; e < 11; e++){
if(Thread::IsShutdownThreads()){break;}
GuiLock __3;
progress = e;
GuiUnlock _3; //It's important to release before Sleep Else the main thread wont be able to refresh GUI during the sleep (because this thread keep the control of GUI))
Sleep(1000);
}
GuiLock __2; //Same as before
button.Enable();
GuiUnlock _2;
return;
});
}
testIndicator(){
Title("Exemple ProgressBar");
SetRect(0, 0, 220, 70);
Add(button.LeftPos(30, 150).TopPos(10, 20));
button.SetLabel("Increase progressBar");
button <<= THISBACK(myCallBack);
Add(progress.LeftPos(10, 200).TopPos(40, 20));
progress.Set(0,10);
}
~testIndicator(){
Thread::ShutdownThreads(); //Thread released
}
};
GUI_APP_MAIN
{
testIndicator().Run();
}
[Updated on: Tue, 24 March 2020 14:24] Report message to a moderator
|
|
|
|
|
|
Goto Forum:
Current Time: Wed Apr 30 03:09:36 CEST 2025
Total time taken to generate the page: 0.00508 seconds
|
|
|