-
July 24th, 2024, 07:38 AM
#1
win32 - How to interrupt execution
Hi,
this seems to be a common task - but I have no idea how to set about, nor could I find any helpful information in the windows manuals.
When my code enters in a lengthy evaluation of data, I want to be able to abort the execution of this loop. I have a dialog with a progress bar and a cancel-Button. But I cannot click this button while the process is running - so I cannot interrupt or abort the process. Here is my code (I am using fortran, if there is a forum on this site better suited for my problem, please let me know):
Code:
hProgress = CreateDialog(NULL, IDD_PROGRESS, hWnd, loc(DN_PrgrsDlgProc))
cRslt = 'Schneller Vorlauf 'C
iRslt = SetDlgItemText (hProgress, IDC_PROGRESSTEXT, cRslt)
iRslt = UpdateWindow (hProgress)
hBar = GetDlgItem (hProgress, IDC_PROGRESSBAR)
iNSteps = (iRunEnd - iiSimZeit) / iiTimeStep
iCount = 0
hAbort= GetDlgItem(hProgress, IDCANCEL)
do
iiSimZeit = iiSimZeit + iiTimeStep
if (iiSimZeit .gt. 0) iRslt = DN_Update() ! t = 0 wird von InitSim gef?llt, daher 0 ?berspringen!
if (iiSImZeit .gt. iRunEnd) exit
iRslt = DN_SetLoad () ! EEG-Erzeugungen bestimmen
iRslt = DN_EuroDispo () ! Strom-Verteilung in Europa
iRslt = DN_AutoDispatch() ! Residuallast ausgleichen
irslt = DN_Eval() ! Netzstr?me errechnen
!iRslt = DN_Redispatch() ! Knotenlasten, d.h. Kraftwerke und Kreise an die Netzkapazit?ten anpassen
iRslt = DN_SumUp () ! Daten zusammenstellen
nRun = nRun + 1
iRslt = DN_OutComes(nRun) ! Ergebnisse ausgeben
iCount = iCount + 1
iRslt = iCount * 100 / iNSteps
iRslt = SendMessage (hBar, PBM_SETPOS, iRslt, 0)
enddo
lRslt = DestroyWindow (hProgress)
The loop runs for several minutes and I want to be able to stop it without stopping the application. I my mind this boils down to the question how I can make the cancel-button to react to mouse input. Once this is possible I may be able to check the state or process messages in my process-dialog-procedure.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|