|
-
Dec 6th, 2002, 12:35 AM
#1
Thread Starter
Hyperactive Member
Detect how a form is closed *[RESOLVED]*
How can i detect if a user has used the close button (X in the upper right area of the form near the minimize and maximize) to close the form...
reason being:
I have my main form hidden to display a splash and login screen.. but if the user hits the X it will show the main form...
I want the application to end if the user hits the X.
any suggestions?
Thanks in advance,
Anjari
Last edited by Anjari; Dec 8th, 2002 at 09:45 AM.
-
Dec 6th, 2002, 01:17 AM
#2
Sorry for the post to another forum but this is a great post:
http://www.gotdotnet.com/community/m...6&Page=1#42609
-
Dec 7th, 2002, 10:42 AM
#3
Thread Starter
Hyperactive Member
Re...
That still didnt help me because at some point during the process I DO want to close that form but when I do it kills my applicacation...
What I have done is created a "login" form....
what happens now is you are prompted for a user name and password and all functions are handled through the Login and cancel buttons... but if you press the x in the top right of the form it will bypass the login and load the main form...
So what I need to know is:
how can i make it so when a user presses the X it will prompt you to make sure you want to close and it will close if you select YES.
But if you log in normally and the form closes it will not have any effect on the rest of the application
Thanks,
Anjari
-
Dec 7th, 2002, 02:18 PM
#4
Did you set the Login form as the startup form? If so then the same rules apply about keeping it open as posted before.
Also you can cancel the Form close through the e parameter, I forget what its called exactly, FormClosingEventArgs I think. Anyway in the properties you'll see a cancel property just set it to TRUE and that will cancel the form closing. If that is what you mean. You can also just put a Msgbox to notify the user.
-
Dec 7th, 2002, 06:24 PM
#5
Thread Starter
Hyperactive Member
no no no
Ok here is what I have...
Form1 = frmMain
Form2 = frmSplash
Form3 = frmLogin
frmMain - hidden at start
frmSplash - shows and is killed 3 seconds later with a timer and opens frmLogin
I want to enforce security to MAKE a user login...
now the way it stands if you hit the X in the upper right corner of the form it will kill the form and show the frmMain form.
I want this to stop! I want to make it so if you hit the x it will prompt you "Are you sure you want to exit this program" without doing this in the form close event. BECAUSE by doing this in the form close event when a user logs in and I unload the form guess what it does? Thats right.... it will prompt the user if they want to close the application..... 
help help help
Thanks,
Anjari
-
Dec 8th, 2002, 08:59 AM
#6
Registered User
One way to do it is to set the ControlBox property of the password form to False.
And show the form as a dialog with ShowDialog() from the main forms load event, that way Main will not be visible until just got past the password form.
Then place the check thing for the password in the OK button code and just...
End
...in the Cancel button code.
-
Dec 8th, 2002, 09:47 AM
#7
Thread Starter
Hyperactive Member
Resolved via another forum here is the link:
http://gotdotnet.com/Community/Messa....aspx?id=57190
Thanks to everyone that tried to help.
Anjari
-
Dec 8th, 2002, 09:56 AM
#8
Registered User
Saw that it was resolved, posting this anyway.... might come to use.....
If you really want to keep the Controlbox you might call the form with something like this.....
Code:
Dim frm As New frmPassword
If frm.Showdialog <> DialogResult.OK then
End
End if
and then set the dialogresult only on the OK button click, that way you will not need to depend on any close events.
Code:
Me.DialogResult = DialogResult.OK
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|