ACTIVATE WINDOW debug PUBLIC loForm loForm = CREATEOBJECT('_Form') loForm.Show() DEFINE CLASS _form AS form top = 0 left = 0 height = 300 width = 300 ADD OBJECT cmdClose AS _commandbutton WITH ; top = 100, ; left = 100, ; height = 27, ; width = 120, ; caption = [Click Me to Test] PROCEDURE QueryUnload *!* some clean up code here IF NOT THIS._PreQueryUnloadHook() RETURN .f. ENDIF THIS.Release() ENDPROC PROCEDURE _PreQueryUnloadHook RETURN .t. ENDPROC ENDDEFINE DEFINE CLASS _commandbutton AS CommandButton PROCEDURE Click THIS.OnClick() ENDPROC PROCEDURE OnClick THISFORM.QueryUnload() ENDPROC ENDDEFINE