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)
Zip file compression in a TopWindow and building progress bar [message #59295] |
Mon, 12 December 2022 21:03  |
BetoValle
Messages: 177 Registered: September 2020 Location: Brasil Valinhos SP
|
Experienced Member |
|
|
Hi,
How do I build a progress bar control ( ProgressIndicator ) into the "ab" function below? Do you have any suggestions?
I've tried several times, but ide won't accept putting it inside the function!
on first compilation it requires a static control. If I create this control, ide reports an error
(): lld-link: error: undefined symbol: pBack::ti
Thanks!
class pBack : public WithpBackLayout<TopWindow> {
public:
typedef pBack CLASSNAME;
pBack();
~pBack();
void FazBackup();
String salvaRegsNoZipFile()
}
Gate2<int, int> WhenProgress; //tipo definido
int ab(int a,int b){
float f= static_cast<double>(a) / b * 100;
//--> here if i put an ProgressIndicator i can't compile !
return WhenProgress(a,b); //função tem que retornar este tipo
}
String pBack::salvaRegsNoZipFile()
{
FileZip zip(fnZip_);
FindFile fff(rrTP[i].nArquivo);
zip.WriteFile(LoadFile(fff.GetPath()), fff.GetName(),ab );
zip.Finish();
}
void pBack::FazBackup()
{
Thread thr;
thr.Run ( [=]
{
...
salvaRegsNoZipFile();
...
}
}
|
|
|
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  |
BetoValle
Messages: 177 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();
...
}
}
|
|
|
Goto Forum:
Current Time: Sun Apr 02 01:50:54 CEST 2023
Total time taken to generate the page: 0.01082 seconds
|