Close program action

estrela666

New member
Joined
Mar 6, 2009
Messages
2
Programming Experience
5-10
Hi!

In my work, we have a program done by other company, and we don't have the code to change it. This program register a serie of numbers and then if the user whants, save them to an xml file. But if the user forget to save and close the program, it doens't ask if whant to save the data, it simply close and all data is lost. I whant to know if its possible to build a vb.net application that controls when the close button is press and freeze the program or something to remind the user to save the data.

Thanks,
Liliana
 
hi,
u can use the 'formclosing' event to check if the data is saved.
Assuming he forms name is form1

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

'to prevent the form from closing u can use the following code
e.cancel=true' the form wont close even if you click the close button
'to close the form u can use
e.cancel =false

End Sub

What you have to do is write the code to check if the save procedure is initiated and if not use e.cancel =true and display a message box or something to prompt the user to save.
 
Zid, I think you missed the part where she said she doesnt have access to the programs source code.

Liliana, using API I have written VB programs that control other executable programs in the past. However I dont think there is an easy way to watch for another forms closing without constantly checking and slowing of the system.

Just some thoughts off the top of my head of things that could be done.

1) Your app could be used to automatically click whatever events are needed to save data in the other program at regular intervals.

2) Your app could disable any controls in the other program that close the program. The user would then have to close by clicking a control on your controled program and at that time you can fire the save event in the other program.

If you not familiar with API and controling other programs though, it is a long process to learn and may be more trouble then your wanting to invest. I have found it very useful to know over the years, Ive ran into many similar situations where companies rely on a software programs that they dont have access to its source code but need to change/update something within it.
 
Back
Top