In the following example, a dialog is created with a radio and two buttons: one to "select" and the other to "cancel" the task without processing anything after the dialog. That is, what follows after the dialog should only be processed if you click on the "Select" button.
The lSelecc variable is initialized as .F. and will only change to .T, if the "Select" button is pressed.
In other words, if you close the dialog with any of the four options other than "Select" (they are: 1.- ESC key, 2.- click on the "Cancel" button, 3.- click on the "X "in the upper right corner of the dialog, and 4.- Press the ALT+F4 keys to close the dialog), the variable" lSelecc "should remain in .F.
This condition is met in the first three cases, but fails in 4 (ALT+F4) that puts the variable in .T. as if you had clicked on the "Select" button.
This happens only with the TBTNBMP class. With the other classes for button handling everything is going well.
How can I fix it or what should I correct in the class? I urgently need to solve it because the process in which this scenario is involved is highly sensitive to the integrity of the client's data.
Thanks in advance for your extraordinary help.
Code: Select all
#include "FiveWin.ch"
Function Main()
LOCAL oDlg, oBtn1, oBtn2, oRad, nOpr:=1
LOCAL lSelecc:=.F. , lNoEsc := .F.
LOCAL aItems := {"Opcion 1","Opcion 2","Opcion 3","Opcion 4","Opcion 5"}
DEFINE DIALOG oDlg FROM 0,0 TO 176,245 PIXEL TITLE "Documentos a Reversar" TRANSPARENT
@ 05, 30 SAY "Seleccione tipo documento:" OF oDlg PIXEL SIZE 100,08
oRad := TRadMenu():New( 15,25,aItems,{|u|If(PCount()==0,nOpR,nOpR:=u)}, oDlg,,,,,,.F.,, 70 , 09,,.F.,.F.,.T.)
@ 68,08 BTNBMP oBtn1 PROMPT "&Select" ACTION ( lNoEsc := .T. , lSelecc:=.T. , oDlg:End()) OF oDlg SIZE 48,14 PIXEL;
LEFT NOBORDER
@ 68,67 BTNBMP oBtn1 PROMPT "&Cancel" ACTION ( lNoEsc := .T. , lSelecc:=.F. , oDlg:End()) OF oDlg SIZE 48,14 PIXEL;
LEFT NOBORDER
ACTIVATE DIALOG oDlg CENTERED VALID lNoEsc
if lSelecc
MsgInfo(nOpr) // <=== *** THIS MUST BE PROCESSED IF, AND ONLY IF, WE CLICK ON THE "SELECT" BUTTON. *** //
endif
Return(NIL)