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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which method of form activated when "Close" cross is pressed 3

Status
Not open for further replies.

benman

Programmer
May 3, 2006
35
HK
Dear All :

Just want to know which method of form is activated when "Close Cross" of Top Left corner of form is pressed.
(shall use to simulate actions of cancel button)

Thanks and happy programming.
Smarty
 
ThisForm.Destroy()


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Scott.... I'd also like to thank you for the info... and to ask if there is a reference somewhere that tells us which method is fired by user actions... It would be very helpful.

Thanks again...

Andy Snyder
SnyAc Software Services
 
SnyAc,
Actually your question is a little amusing... Methods are fired ONLY by calling them. Events are fired by user interaction. If you look at the "Methods" tab, depending on your version of VFP you will see some of them with the word (Event) next to them (or a lighting bolt), which indicates they are events that "Fire" automatically. If you click on them, in the bottom of the properties window, it gives a brief descritption of what "causees" them to fire. This is why you can add "Methods" to a form, but not "Events"... because the events themselves are quite special, and VFP does not have a way of allowing users to create their own "Event Model". (You can do this in C++ and other languages, but you are also responsible for ALL kinds of things that VFP takes care of for you).
Likely, if you are creating database apps, you don't really have a need for this anyway, though just now and again, I wish I could create my own events! But it is very tricky to create and manage an event model.
I have seen in the help file as well, the triggering of the "Event" model, for instance what the sequence of events in terms of things like the Init Event, and the Activate Event (which comes first), but off the top of my head, I don't remember where I found it. I would suggest doing a search in the help file for something like "Event Sequence" or just EVENTS in the Search, and see what options come up.


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 

Smarty,

Scott said that it's the form's Destroy that's called when you close the form. That's perfectly true, but it's not the whole story.

In addition, the following events will fire (not necessarily in this order):

- QueryUnload

- The LostFocus of whichever control has focus

- The form's Deactivate.

- The form's Unload.

Possibly a couple of others that don't come immediately to mind.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike is correct... and the key to remember here is that it is the Form's UNLOAD event that happens last.



Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
SnyAc said:
.. and to ask if there is a reference somewhere that tells us which method is fired by user actions...
In the VFP online help index, search for 'events' and then choose the item 'sequence in Visual Foxpro'. It contains an example of a user using a form to enter data, and which events are fired along the way. Not overly robust, but it's a start.

Mike Krausnick
Dublin, California
 
Thanks Mike.... I'll certainly give it a look... it's bound to help as I maintain the existing forms and as I add new ones.

Andy Snyder
SnyAc Software Services
 
FYI... in VFP8 help the item is 'Tracking Event Sequences'. Very informative and helpful in understanding how the event sequences inter-relate. Thanks again Mike...

Andy Snyder
SnyAc Software Services
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top