SetTimer ?
-
I have a dialog with a button and a progressbar. When the user clicks the button a lengthy process is initiated. During this process I want increment the progressbar on a regular interval. I did this by setting a timer when the button is clicked, but the OnTimer function is never called. However it is called when I set the timer in the OnInitDialog function. It seems that the lengthy process that is initiated in the 'OnMyButtonClicked' function blocks the timer. Anyone knows a sollution for this problem?
-
I have a dialog with a button and a progressbar. When the user clicks the button a lengthy process is initiated. During this process I want increment the progressbar on a regular interval. I did this by setting a timer when the button is clicked, but the OnTimer function is never called. However it is called when I set the timer in the OnInitDialog function. It seems that the lengthy process that is initiated in the 'OnMyButtonClicked' function blocks the timer. Anyone knows a sollution for this problem?
I am not sure if this will help, but does this "lengthy process" have a DO/FOR/WHILE loop? If so the task is fairly straight forward. Here is an example of a ProgressBar function: void CMyDialog::ProgressBar() { int percentage=0; //variable initialisation char temp[100]; // //The following line will calculate the Progress bar percentage //The "Records" is a global UINT which increments each time through the loop //The "TotalRecords" is the total number of Records in the loop percentage=(int)(((float)Records/(float)TotalRecords)*100.0); //"m_Progress" is the variable attached to your dialog //This will set the position of the progress bar depending on the percentage m_Progress.SetPos(percentage); //This will update the "m_Progress" variable with the new position UpdateData(FALSE); } Call this function every time you wish to update the progress bar. Dont forget to update the "Records" variable before calling this function. Hope this helps. :)