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 » U++ Library support » TopWindow&PopUp, TrayIcon » Zip file compression in a TopWindow and building progress bar (adapting the gate in the progressive control structure)
Re: Zip file compression in a TopWindow and building progress bar [message #59323 is a reply to message #59295] Wed, 14 December 2022 03:24 Go to previous message
BetoValle is currently offline  BetoValle
Messages: 203
Registered: September 2020
Location: Brasil Valinhos SP
Experienced Member
Hi,

I was able to come up with a solution (successfully tested) using a new tread that contains a ProgressIndicator!

I'll put it on record here for anyone who might take advantage of it.

Thanks


class pBack : public WithpBackLayout<TopWindow> {
public:
		  		
     typedef pBack CLASSNAME;
     pBack();
     ~pBack();	
     
     void FazBackup();
     String salvaRegsNoZipFile()

     void newThread();//***
	
}	

pBack::~pBack()
{
   ShutdownThreads();
}

int aa,bb;   //***
float ff;    //***
bool ok;     //**

void pBack::newThread()
{
	
		Thread thr2;
		thr2.Run ( [=]
		{
			While ok {
				  
	                    if ( IsShutdownThreads() )
			      break;
	      
	                    GuiLock _b1; 
		            Pi.Set(aa,bb);  // ProgressIndicator build in file.lay!
	                    GuiUnlock __b1;				
				  
			    Sleep(20);
			}
		}	
	
}

Gate2<int, int> WhenProgress;        
int ab(int a,int b){          
  float f= static_cast<double>(a) / b * 100;

  aa=a;//***
  bb=b;//***
  ff=f;//***

  return WhenProgress(a,b);           
}

String pBack::salvaRegsNoZipFile()
{
  FileZip zip(fnZip_);
 	FindFile fff(rrTP[i].nArquivo);
 	
 	ok=true;     //**
 	newThread(); //**
	
	zip.WriteFile(LoadFile(fff.GetPath()), fff.GetName(),ab );
	
	ok=false;   //**
	
	
	zip.Finish();
}

void pBack::FazBackup()
{
		Thread thr;
		thr.Run ( [=]
		{
			...
			salvaRegsNoZipFile();
			...
		}
}

 
Read Message
Read Message
Previous Topic: Multi monitor support
Goto Forum:
  


Current Time: Tue May 07 06:00:24 CEST 2024

Total time taken to generate the page: 0.03323 seconds