|
-
Jul 28th, 2008, 05:25 AM
#1
Thread Starter
Lively Member
[urgent] "X" button
how can i control the "X" button
on the upper right of the Form??
Note: Upper Right of the form...
plsss help me
-
Jul 28th, 2008, 05:41 AM
#2
Frenzied Member
Re: [urgent] "X" button
What do you mean by "control". CHeck out the post titled:
Can I stop a form closing when the Close button is clicked?
-
Jul 28th, 2008, 05:44 AM
#3
Thread Starter
Lively Member
Re: [urgent] "X" button
yes that's what i mean...
is there such code that control
the "X" button???
-
Jul 28th, 2008, 05:59 AM
#4
Frenzied Member
Re: [urgent] "X" button
Post titled'
"How to stop closing form?"
-
Jul 28th, 2008, 07:38 AM
#5
Re: [urgent] "X" button
 Originally Posted by ken_coffee
yes that's what i mean...
is there such code that control
the "X" button???
Use the FormClosing and/or the FormClosed events to do what's needed
-
Jul 28th, 2008, 09:37 AM
#6
Re: [urgent] "X" button
 Originally Posted by JuggaloBrotha
Use the FormClosing and/or the FormClosed events to do what's needed
Not such a good idea. There's no way to specifically distinguish between the user clicking the Close box (as it's officially named) and your code calling Me.Close.
Prevention is better than cure. If you don't want the user to use the Close box then it's best to disable it. There's a link in my signature that demonstrates how to do that.
-
Jul 28th, 2008, 09:48 AM
#7
Re: [urgent] "X" button
 Originally Posted by jmcilhinney
Not such a good idea. There's no way to specifically distinguish between the user clicking the Close box (as it's officially named) and your code calling Me.Close.
Prevention is better than cure. If you don't want the user to use the Close box then it's best to disable it. There's a link in my signature that demonstrates how to do that.
Well no but its very easy to implement something to check that... just a simple boolean value that you set to True when you do want the program to close works fine for me.
Also there's the CloseReason property that is passed to the FormClosing event through the e argument that lets you determine whether the user is closing the form or if windows is shutting down the form etc.
example:
Code:
Public Class Form1
Dim letmeclose As Boolean = False
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If letmeclose = False Then
e.Cancel = True
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
letmeclose = True
Me.Close()
End Sub
End Class
I do agree that most of the time prevention is better than the cure but to me disabling the X makes the program look unprofessional as you very rarely see a decent peice of software that does that... so its better for me to just make a warning message appear or something when the user clicks the X. I guess its just a personal preference though?
Last edited by chris128; Jul 28th, 2008 at 09:53 AM.
-
Jul 28th, 2008, 09:53 AM
#8
Re: [urgent] "X" button
 Originally Posted by chris128
Well no but its very easy to implement something to check that... just a simple boolean value that you set to True when you do want the program to close works fine for me.
Also there's the CloseReason property that is passed to the FormClosing event through the e argument that lets you determine whether the user is closing the form or if windows is shutting down the form etc.
example:
Code:
Public Class Form1
Dim letmeclose As Boolean = False
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If letmeclose = False Then
e.Cancel = True
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
letmeclose = True
Me.Close()
End Sub
End Class
All true but, regardless of any of that, prevention is better than cure. If the user can't use the Close box then it really is preferable to disable it. It's pretty annoying as a user to have something presented to you as though you can use it and then have a message pop up and say that you can't. Worse still, if you don't display a message then the user may think your app is broken because a standard piece of Windows functionality is present but doesn't do what it's supposed to do.
-
Jul 28th, 2008, 09:36 PM
#9
Thread Starter
Lively Member
Re: [urgent] "X" button
i got your points
^_^
tnx alot
u give me a real
point of view on
what shoud i do and not to do
thx alot buddies
^_^
more support for a newbie ^_^
ty
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
|