>************************************************** >oForm = Createobject('frmBase') >oForm.Show(1) > >Define Class frmbase As Form > > Caption = "FormBase" > KeyPreview = .T. > *-- Reflects the answer to the questions, whether the user wants to close the form. > lreleaseapproved = .F. > Name = "frmbase" > > Add Object cmdexit As CommandButton With ; > Top = 120, ; > Left = 190, ; > Height = 27, ; > Width = 84, ; > Caption = "E\<xit", ; > Name = "cmdExit" > > Procedure KeyPress > Lparameters nKeyCode, nShiftAltCtrl > If nKeyCode = 27 And nShiftAltCtrl = 0 > Nodefault > Thisform.Release > Endif > DoDefault() > Endproc > > Procedure Init > If !DoDefault() > Return .F. > Endif > With Thisform > .lreleaseapproved = .F. > .AutoCenter = .T. > .AutoCenter = .F. > Endwith > Endproc > > Procedure OnClose > Messagebox('Do some useful code here!') > Endproc > > Procedure QueryUnload > Local lnAnswer As Integer > With This As Thisform > If .lreleaseapproved = .F. > m.lnAnswer = Messagebox( ; > 'Would you really like to close down?', ; > 4+32+256+4096, .Caption) > If m.lnAnswer = 6 > .lreleaseapproved = .T. > .OnClose() > DoDefault() > Else > .lreleaseapproved = .F. > Nodefault > Endif m.lnAnswer = 6 > Else > DoDefault() > Endif .lreleaseapproved = .F. > Endwith > Return > Endproc > > Procedure Release > Local lnAnswer As Integer > With This As Thisform > If .lreleaseapproved = .F. > m.lnAnswer = Messagebox( ; > 'Would you really like to close down?', ; > 4+32+256+4096, .Caption) > If m.lnAnswer = 6 > .lreleaseapproved = .T. > .OnClose() > DoDefault() > Else > .lreleaseapproved = .F. > Nodefault > Endif m.lnAnswer = 6 > Else > DoDefault() > Endif .lreleaseapproved = .F. > Endwith > Return > Endproc > > Procedure Unload > Nodefault > *--- Do whatever needed at the very end like CLEAR EVENTS > DoDefault() > Endproc > > Procedure cmdexit.Click > Thisform.Release() > Endproc > >Enddefine >************************************************** >>