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. Newbie: How do I make a progress dialog?

Newbie: How do I make a progress dialog?

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorialannouncement
3 Posts 3 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.
  • M Offline
    M Offline
    maxmaven
    wrote on last edited by
    #1

    Hi, Do any of you know how to make a progress dialog? I am writing out my data in my CDocument class. I have a menu and a toolbar icon called "process and write out data". I want the progress dialog to update the progress ctrl as work is finished. I was hoping that the right way to do this is to manage the progress dialog updates in my cdocument, since that is where all my data is. Can you give me a little pseudocode that explains how this would work? Or should I be doing it another way? Thanks, Max

    B PJ ArendsP 2 Replies Last reply
    0
    • M maxmaven

      Hi, Do any of you know how to make a progress dialog? I am writing out my data in my CDocument class. I have a menu and a toolbar icon called "process and write out data". I want the progress dialog to update the progress ctrl as work is finished. I was hoping that the right way to do this is to manage the progress dialog updates in my cdocument, since that is where all my data is. Can you give me a little pseudocode that explains how this would work? Or should I be doing it another way? Thanks, Max

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

      Most peoples gut reaction to progress bars is something like this... m_wndProgress.SetRange32(0,500); m_wndProgress.SetPos(0); for (int i=0;i<500;++i) { Sleep(50); // Just to slow this down for demo /* do work here */ m_wndProgress.SetPos(i); } However, if you drop this code into a button click handler in a dialog with a progress bar, you'll notice the dialog becomes unresponsive to any user actions such as closing the dialog. If processing your work takes enough time to require a progress bar, then it probably should allow the user to cancel or abort the activity. The easiest way to perform some lengthy processing while leaving the GUI thread free to respond to the user is to perform the processing in a separate worker thread. The worker thread then can post messages to the GUI thread to allow it to update the progress bar. This allows the GUI's message loop to process in a normal fashion. When we had the GUI thread performing the work as in the snippet above, message processing for the dialog had to wait for the loop to finish. Unresponsive GUI's are a good recipe for short tempers. Look up AfxBeginThread() for MFC threading Not quite pseudocode but I hope it helps get the wheels turning.

      1 Reply Last reply
      0
      • M maxmaven

        Hi, Do any of you know how to make a progress dialog? I am writing out my data in my CDocument class. I have a menu and a toolbar icon called "process and write out data". I want the progress dialog to update the progress ctrl as work is finished. I was hoping that the right way to do this is to manage the progress dialog updates in my cdocument, since that is where all my data is. Can you give me a little pseudocode that explains how this would work? Or should I be doing it another way? Thanks, Max

        PJ ArendsP Offline
        PJ ArendsP Offline
        PJ Arends
        wrote on last edited by
        #3

        http://www.codeproject.com/miscctrl/progresswnd.asp[^]


        Darker than a black steer's tookus on a moonless praire night

        Within you lies the power for good, use it!!!

        Within you lies the power for good; Use it!

        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