* QueryUnload IF YourConditionExists MessageBox("Yourmessage",0,"Important") Nodefault RETURN ENDIF * Here you would do whatever you need to do in the releasing of the formAs for disabling the "X", that can be done by making the form's Closeable property False (.F.) as in;
Thisform.Closeable = .F.
Personally, I like making the form NOT closeable when necessary rahter than trappiung the close operation and frustrating it. The latter approach can be irritating to the user as they see the X is enabled, they click it expecting the fomr to close and then they are told that the form cannot close. As a user I would ask, "If the form knew it couldn't close why did it let me click the X?"