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. Cancelling a long process

Cancelling a long process

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++comhardwaretutorial
3 Posts 2 Posters 1 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
    Mark Donkers
    wrote on last edited by
    #1

    Hello everyone, Wow. It's been a while since I've been here. I was doing some embedded stuff there for a while. It's nice to be back. Anyway, the question that I had has to do with having the ability to cancel a process that is in the middle of a for() loop. What I would like is a dialog that pops up on the over the application window that simply says "Cancel". I was reading used the code from Nishant's article Tutorial - Modeless Dialogs with MFC (http://www.codeproject.com/dialog/gettingmodeless.asp#xx211427xx). I've declared my modeless dialog as a local variable in the function with the loop. In the loop I want to check to see if the Cancel button was pressed. When I enter my loop, I can't press the Cancel button. Any ideas?? Thanks in advance. LONG CTest3431::TestKeypad() { LONG lRetVal = 0; CCancelDlg dlgCancel; dlgCancel.SetProgressText("Running keypad test..."); dlgCancel.ShowWindow(SW_SHOW); .... for( i=0; i<sizeof(sbKeys); i++ ) { if( dlgCancel.IsOperationCancelled() ) { lRetVal = -1; break; } .... } Mark Donkers A witty saying proves nothing. -- Voltaire

    RaviBeeR 1 Reply Last reply
    0
    • M Mark Donkers

      Hello everyone, Wow. It's been a while since I've been here. I was doing some embedded stuff there for a while. It's nice to be back. Anyway, the question that I had has to do with having the ability to cancel a process that is in the middle of a for() loop. What I would like is a dialog that pops up on the over the application window that simply says "Cancel". I was reading used the code from Nishant's article Tutorial - Modeless Dialogs with MFC (http://www.codeproject.com/dialog/gettingmodeless.asp#xx211427xx). I've declared my modeless dialog as a local variable in the function with the loop. In the loop I want to check to see if the Cancel button was pressed. When I enter my loop, I can't press the Cancel button. Any ideas?? Thanks in advance. LONG CTest3431::TestKeypad() { LONG lRetVal = 0; CCancelDlg dlgCancel; dlgCancel.SetProgressText("Running keypad test..."); dlgCancel.ShowWindow(SW_SHOW); .... for( i=0; i<sizeof(sbKeys); i++ ) { if( dlgCancel.IsOperationCancelled() ) { lRetVal = -1; break; } .... } Mark Donkers A witty saying proves nothing. -- Voltaire

      RaviBeeR Offline
      RaviBeeR Offline
      RaviBee
      wrote on last edited by
      #2

      Use PeekMessage(). See this article[^] for an example. /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com

      M 1 Reply Last reply
      0
      • RaviBeeR RaviBee

        Use PeekMessage(). See this article[^] for an example. /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com

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

        That did the trick. Thanks Ravi! MD Mark Donkers A witty saying proves nothing. -- Voltaire

        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