PROCEDURE mnuFileExit(oform) IF OkayToExitMyProgran(oform) xitMyProgram(oform) ELSE * ignore ENDIF endprocThe forms queryunload had a similar method:
IF OkayToExitMyProgram(this) xitMyProgram(this) ELSE NODEFAULT ENDIFThe routine to assure the user really wants to close, looked like this:
PROCEDURE OkayToExitMyProgram(oform) IF VARTYPE(SomeOtherModelessForm)==[O] SomeOtherModelessForm.Activate && Place it on top of any other SomeOtherModelessForm.txtFB.SetFocus && forms so the msgbox be on top ELSE ENDIF IF MESSAGEBOX([Exit MyProgram?],[Exit],4+32+256)=6 llReturnFlag=.t. ELSE llReturnFlag=.f. ENDIF RETURN llReturnFlag ENDPROCThis method closed it:
PROCEDURE xitMyProgram(oform) IF VARTYPE(SomeOtherModelessForm)==[O] SomeOtherModelessForm.QueryUnload SomeOtherModelessForm.Release ELSE ENDIF oform.release CLEAR EVENTS ENDPROCBoth the menu bar and the ocxToolBar button called "mnuFileExit" (above). The menu bar worked and the form [X]close (QueryUnload) worked. However, when the ToolBar button was used to call "mnuFileExit", the messagebox in "OkayToExitMyProgram" was called (recycled?) again. Debug did not trace the routing back to the method, the messagebox just appeard when debug arrived at form.release.