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. Dialog question

Dialog question

Scheduled Pinned Locked Moved C / C++ / MFC
c++databasehelpquestion
4 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.
  • Y Offline
    Y Offline
    yellowine
    wrote on last edited by
    #1

    I am using MFC's CDialog derived class to do some lengthy task. I use a button to trigger the process. The problem I am having is: after I click the button, the lengthy task begins. However, after I switch to other programs, the dialog won't respond my click on it until the task is done. Is there any way I can do to get rid of the problem.

    C B 2 Replies Last reply
    0
    • Y yellowine

      I am using MFC's CDialog derived class to do some lengthy task. I use a button to trigger the process. The problem I am having is: after I click the button, the lengthy task begins. However, after I switch to other programs, the dialog won't respond my click on it until the task is done. Is there any way I can do to get rid of the problem.

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      It's normal: your application has only one thread, in which the Windows messages are processed (mouse click, click on button, ...). So, if in this thread you start a lenghty process, Windows messages are not processed anymore and your GUI will freeze (not able to respond to any messages, event not the WM_PAINT message). The solution is to start this process in a separate thread and to keep the main dialog informed about the status by sending custom messages to it. I suggest you read this excellent article[^], it's worth the time you will take to read it.

      Cédric Moonen Software developer
      Charting control [v1.5] OpenGL game tutorial in C++

      1 Reply Last reply
      0
      • Y yellowine

        I am using MFC's CDialog derived class to do some lengthy task. I use a button to trigger the process. The problem I am having is: after I click the button, the lengthy task begins. However, after I switch to other programs, the dialog won't respond my click on it until the task is done. Is there any way I can do to get rid of the problem.

        B Offline
        B Offline
        bxveer
        wrote on last edited by
        #3

        I had the same issue and found a simple solution. In the process/task that you are triggering from this dialog, insert the following code so it gets called periodically while that process/task progresses. MSG msgs; while( ::PeekMessage( &msgs, NULL, 0, 0 , PM_NOREMOVE ) ) { if( !AfxGetThread()->PumpMessage() ) { ::PostQuitMessage(0); break; } }

        Y 1 Reply Last reply
        0
        • B bxveer

          I had the same issue and found a simple solution. In the process/task that you are triggering from this dialog, insert the following code so it gets called periodically while that process/task progresses. MSG msgs; while( ::PeekMessage( &msgs, NULL, 0, 0 , PM_NOREMOVE ) ) { if( !AfxGetThread()->PumpMessage() ) { ::PostQuitMessage(0); break; } }

          Y Offline
          Y Offline
          yellowine
          wrote on last edited by
          #4

          It works. Thanks a lot.

          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