Xemuth Messages: 387 Registered: August 2018 Location: France
Senior Member
idkfa46 wrote on Tue, 24 March 2020 15:41
Thank you for your support! Your solution is really interesting but the easiest solution is to call
ProcessEvents();
as suggested me by Omari.
Best,
Matteo
Indeed, it work as well without a thread ! the only default of this methode is (if I put it in my exemple) the gui is still lock during the Sleep function which is normal.
Their is howerver many workarround like doing this kind of things :
void myCallBack(){
button.Disable(); //Action on GUI
ProcessEvents();
for(int e = 0; e < 11; e++){
progress = e;
ProcessEvents();
for(int i = 0; i < 100; i++){
Sleep(10);
ProcessEvents();
}
//Same as Sleep(1000) but with a better control on GUI (however it wont 'sleep' for
// 1 second now, but for 1 sec + 100 * (processEvents() Time)
}
button.Enable();
ProcessEvents();
return;
}