Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » ProgressIndicator issue
Re: ProgressIndicator issue [message #53228 is a reply to message #53223] Tue, 24 March 2020 14:21 Go to previous messageGo to previous message
Xemuth is currently offline  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

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Help & Topics (in tab)
Next Topic: [SOLVED] Cloning Array of complexe type
Goto Forum:
  


Current Time: Sun Aug 24 19:23:38 CEST 2025

Total time taken to generate the page: 0.04814 seconds