Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

override form release

Status
Not open for further replies.

flurf

Programmer
Oct 30, 2001
3
0
0
US
in a vfp6 form, is there some way to override the 'release', 'destroy', 'unload', or whatever event gets triggered when you click the X in the form's control box [the upper right corner of the form with the 'restore', 'maximize', and 'close' buttons]?

same question for formsets - if a parent object releases the formset, is there a way to override the release somehow through run-time code?
 
You create a form level variable.. lClose
Initialise the value with .f.

You change this value to .t. when you want the release destroy unload events to fireup.

In the destroy/unload/release events.. put the code...
IF NOT THISFORM.lClose
NODEFAULT
ELSE
DODEFAULT()
ENDIF

Hope this helps:)

Unless the lClose is changed to .t., you wont be able to close the form. I have not tested this code, as such an occasion never came to me.

ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
HI
If you dont want the x at the forms top right disabled... you can st the CLOSABLE property of the form to .f.
ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
well, it looks like the lClose variable is just a wrapper for the meat of the answer, which is the NoDefault and DoDefault functions placed in the release event's code of the form/formset. gotta go look those up on msdn.

thanks for guiding me in the right direction!
 
i tried adding NoDefault outside of any If structure, just by itself, to the Destroy, Release, and Unload methods of a form. This did not prevent the form from unloading in any way.

HELP!!!
 
The intuitively(?) named QueryUnload() is called when the form close button (the 'x' in the top right corner) is clicked. Try putting your NODEFAULT logic there.

Rick
 
You need to put it in the QueryUnload event of the form. I have no idea why, so don't ask me. :)

I have an app that can be run in the system tray or as a standard app. Here's the code in my QueryUnload event of the main form:

IF GetSysData("SYSTRAY") THEN
NODEFAULT
This.Visible = .f.
ELSE
DO ExitApp
ENDIF

(GetSysData() is my wrapper function for handling globals...if running in system tray, just hide the form, otherwise unload it on exit.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top