Hello,
I have created a windows program containing a number of dialogs. Only two of them have OK and Cancel buttons. I'll use one of these two dialogs in the info below.
Here is the definition of its creation:
CreateDialog ScreenFileEdit,0,0,400,260,@MINBOX|@MAXBOX|@SIZE|@CAPTION|@SYSMENU,0,"Screen File Edit",&ScreenFileEdit_handler
CONTROL ScreenFileEdit,@BUTTON,"OK",82,213,60,25,0,ScreenFileEdit_OKbtn
CONTROL ScreenFileEdit,@BUTTON,"Cancel",216,213,60,25,0,ScreenFileEdit_Cancel
CONTROL ScreenFileEdit,@STATIC,"SCREEN File Data",48,8,309,25,@SS_SIMPLE,ScreenFileEdit_STATIC1
CONTROL ScreenFileEdit,@STATIC,"Starting X:",85,69,140,25,@SS_SIMPLE,ScreenFileEdit_STATIC2
CONTROL ScreenFileEdit,@STATIC,"Starting Y:",86,104,138,25,@SS_SIMPLE,ScreenFileEdit_STATIC3
CONTROL ScreenFileEdit,@EDIT,"Starting X",245,69,34,25,@CTEDITCENTER,ScreenFileEdit_X
CONTROL ScreenFileEdit,@EDIT,"Starting Y",246,106,34,25,@CTEDITCENTER,ScreenFileEdit_Y
I display this dialog using the statements:
DOMODAL ScreenFileEdit, w
WAITUNTIL ISWINDOWCLOSED(ScreenFileEdit)
The handler for this dialog:
SUB ScreenFileEdit_handler (), INT
SELECT @MESSAGE
CASE @IDINITDIALOG
CENTERWINDOW ScreenFileEdit
SETCONTROLTEXT ScreenFileEdit,ScreenFileEdit_X, str$(sfx)
SETCONTROLTEXT ScreenFileEdit,ScreenFileEdit_Y, str$(sfy)
CASE @IDCONTROL
SELECT @CONTROLID
CASE ScreenFileEdit_OKbtn
IF @NOTIFYCODE = 0
'OK button clicked
CLOSEDIALOG ScreenFileEdit,@IDOK
ENDIF
CASE ScreenFileEdit_Cancel
IF @NOTIFYCODE = 0
h_x = "": h_y = "" 'Reset these on a Cancel.
CLOSEDIALOG ScreenFileEdit,@IDCANCEL
ENDIF
CASE ScreenFileEdit_X
h_x = GetControltext(ScreenFileEdit,ScreenFileEdit_x)
CASE ScreenFileEdit_Y
h_y = GetControltext(ScreenFileEdit,ScreenFileEdit_y)
ENDSELECT
ENDSELECT
RETURN
ENDSUB
The user can view the dialog and make changes if he wants. He presses OK or the Cancel button to close it. If he pressed OK, the program edits any changes and saves the new data. The program continues on with other activities. The user is supposed to be able to call up this dialog any number of times during program execution.
The problem is that the second time he calls the dialog and presses OK or Cancel, the program immediately quits. It doesn't matter whether he pressed OK the first time and OK the second, or OK the first and Cancel the second, or any other combination. In fact, if the user called one of these two dialogs the first time and the other the second time, the program quits.
Any ideas?
Thanks for your help.
You are missing RETURN 0 (you have only RETURN) from your dialog SUB
Brian
Not sure if this is the exact answer you need, but from the Doc:
Note that any controls in the dialog cannot be initialized until the dialog is displayed. All control initialization should be done in the dialog handler subroutine in response to the @IDINITDIALOG message.
Bill
Brian,
I added 0 to the RETURN statement in the handler subroutine but it had no effect.
Bill - I'm already initializing my dialog controls with the @IDCONTROL.
Apology necessary:
I discovered a program error that was causing the dialog problem symptoms. This happens when one is developing a program and have temporary code inserted all over the place to test things as you develop. The program was getting into code it shouldn't have.
Sorry for any inconvenience and brain cell damage, Bill and Brian.
Not a problem. Been there and done that. You actually learn the language better by your mistakes than you do by what works without any problems.
Bill