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. make dialog responsive even if it is running a time consuming calculation

make dialog responsive even if it is running a time consuming calculation

Scheduled Pinned Locked Moved C / C++ / MFC
mobiletutorial
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.
  • S Offline
    S Offline
    swarup
    wrote on last edited by
    #1

    hi guys i have a dialog based application, when i run a time consuming operation, the dialog box hang, becas unless the operation completes my dialog box wont have any focus or will nt be able to recieve any message. Example: i have a listctrl where i add 10000 records, so unless all records are added my dialog will nt respond. where as while those records being added i want my dialog box to be responsive, i cant let the user to wait till the operation gets over, any idea, there is a code sample called backgroundtask dialog here CP, i dont want that way. Swarup

    M M 2 Replies Last reply
    0
    • S swarup

      hi guys i have a dialog based application, when i run a time consuming operation, the dialog box hang, becas unless the operation completes my dialog box wont have any focus or will nt be able to recieve any message. Example: i have a listctrl where i add 10000 records, so unless all records are added my dialog will nt respond. where as while those records being added i want my dialog box to be responsive, i cant let the user to wait till the operation gets over, any idea, there is a code sample called backgroundtask dialog here CP, i dont want that way. Swarup

      M Offline
      M Offline
      Mario M 0
      wrote on last edited by
      #2

      Have a look here http://www.flounder.com/workerthreads.htm[^]

      1 Reply Last reply
      0
      • S swarup

        hi guys i have a dialog based application, when i run a time consuming operation, the dialog box hang, becas unless the operation completes my dialog box wont have any focus or will nt be able to recieve any message. Example: i have a listctrl where i add 10000 records, so unless all records are added my dialog will nt respond. where as while those records being added i want my dialog box to be responsive, i cant let the user to wait till the operation gets over, any idea, there is a code sample called backgroundtask dialog here CP, i dont want that way. Swarup

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        Doing your lengthy process on a separate thread is the recommended way to go. If you don't want to use multiple threads, then your lengthy process needs to periodically pump all Windows messages so the UI will remain responsive. Here's an example MFC message pump (implemented in the application class)

        void CMyWinApp::PumpWaitingMessages()
        {
        MSG msg;
        while ( ::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
        {
        if ( !PumpMessage( ) )
        {
        //::PostQuitMessage(0);
        break;
        }
        }
        }

        A Win32 message pump could be something like

        MSG msg;
        while ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
        {
        TranslateMessage( &msg );
        DispatchMessage( &msg );
        }

        Note that you'll want to disable any UI components that you don't want the user to mess with during the lengthy process. Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        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