Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. SetTimer ?

SetTimer ?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Brian van der Beek
    wrote on last edited by
    #1

    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?

    B 1 Reply Last reply
    0
    • B Brian van der Beek

      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?

      B Offline
      B Offline
      Bryster
      wrote on last edited by
      #2

      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. :)

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups