Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Exception handling of running functions in a dialog
#2
first off you need to use opt waitmsgn in a dialog if you use any kind of wait function


about func3:
line 1.
Will pop up an error message,I don't want to pop up an error warning, I need to continue

fix
use run flag 0x100 (0x100On error, don't show error message box.)
line 2.
Dialog will lose response, QM quit unexpectedly, dialog crashes

fix
use opt waitmsg 1 before calling func3

 "My Request:"
1.When the above three lines of code have an error, run the 5th line code directly.

see code below with fixes

Function func3
Code:
Copy      Help
int ErrorCount
run "abc" "" "" "" 0x100;err ErrorCount+1
int w=wait(5 WA win("" "Notepad")); err ErrorCount+1
act w; err ErrorCount+1
if(ErrorCount>0) 
,MES m.timeout=3; m.style="OCa"; m.default='C'
,mes(F"There are already {ErrorCount} lines of commands skipped above" "" m)

Macro Macro8
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Button 0x54032000 0x0 88 48 48 14 "func3"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

if(!ShowDialog(dd &sub.DlgProc 0)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 3 ;;func3
,opt waitmsg 1
,func3
ret 1

Quote:2.Executing some function through the button in the dialog box, any abnormality in the function will cause the dialog box to close unexpectedly, how to prevent it?
 use err block
Code:
Copy      Help
err-
;your code goes here
err+

this will allow the code to continue on and not end


Messages In This Thread
RE: Exception handling of running functions in a dialog - by Kevin - 06-29-2019, 03:30 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)