Cancelling a long process
-
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 -
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. -- VoltaireUse
PeekMessage()
. See this article[^] for an example. /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.com -
Use
PeekMessage()
. See this article[^] for an example. /ravi Let's put "civil" back in "civilization" http://www.ravib.com ravib@ravib.comThat did the trick. Thanks Ravi! MD Mark Donkers A witty saying proves nothing. -- Voltaire