Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Handling cancel button

tmcole
Beginner
1,088 Views
I've searched the help files, but cannot find anything that tells me how to handle when the "cancel" button has been pushed. I see that it has the ID of IDCANCEL, but apparently nowhere in the documentation does it tell how to access the value of IDCANCEL in order to determine if it has been pushed. Anyone now how?
0 Kudos
6 Replies
alfredwodell
Beginner
1,088 Views
'use dflogm' will allow you to access IDCANCEL.
(Its value is 2)
0 Kudos
tmcole
Beginner
1,088 Views
Alfred, thanks. Now, can anyone tell me if there is a way to automatically cause OK to be clicked on so as to return without requiring the user to click on it? The reason why is that I have quickly become enamored with dialog boxes and want to use one to automatically output the status of my program as it is running. Thanks.
0 Kudos
meistrv
Beginner
1,088 Views
The button you want to be pushed on should have the "default button" property checked. It it under properties - styles.
0 Kudos
tmcole
Beginner
1,088 Views
I am using DFLOGM, but cannot acccess IDCANCEL (in the debugger at least), which is why I posted the question. So, in my case, I cannot query what the value of IDCANCEL is in order to write logic on how to handle execution when the cancel button is pushed. Any further thoughts?
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,088 Views
IDCANCEL (=2) and IDOK (=1) are PARAMETERs so you can't view them in the debugger.

IDCANCEL message is generated whenever user presses Esc key. Similarly, when user presses Enter key, the dialog is searched for the button with "Default" property, and if there's one, appropriate ID message is generated. IDOK button has "Default" property in the resource editor by default.

Now, I'm not sure what happens if there's no button with ID=2=IDCANCEL; I think the cancel message is not generated, i.e. your callback will not be called. In any case, you may safely hide buttons with IDOK and IDCANCEL buttons.

See also DLGSETRETURN and DLGEXIT routines.

Jugoslav
0 Kudos
Intel_C_Intel
Employee
1,088 Views
How to handle the cansel button? This is what I do:

    	retint = DlgModal (MyDialogName)
	If (retint == 1) Then   ! This is OK button
          Do something, e.g. CONTINUE
	Else If (retint == 2) Then   ! This is cansel button
	  i = MESSAGEBOXQQ ('Do you want to exit the program?'C,
     &		'Exit...'C, MB$YESNO.OR.
     &		MB$ICONQUESTION)
	  If (i == 6) Then  ! This is Yes
            Do something, e.g. RETURN
	  Else
		Do something else, e.g. go to previous lines to reinitialize the dialog
	  End If
	End if


(Cut and paste makes "wide screen"!)

Sabalan.
0 Kudos
Reply