|
-
Sep 26th, 2002, 01:27 AM
#1
Thread Starter
New Member
how does the form Closing event work
I just using vb .NET and i'm familiar with vb 6.0 event QueryUnload, but how do you implement the closing event from vb .NET.
-
Sep 26th, 2002, 01:43 AM
#2
The closing event works basically like the Form_Unload event or QueryUnload event but there is no known way to catch the reason the form is closing. .NET doesn't have anything like the UnloadMode in VB6.
-
Sep 26th, 2002, 09:09 AM
#3
Member
the closing event is
Private Sub form1_closing(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closing
that what you wanted?
J
-
Sep 26th, 2002, 03:41 PM
#4
Originally posted by Edneeis
The closing event works basically like the Form_Unload event or QueryUnload event but there is no known way to catch the reason the form is closing. .NET doesn't have anything like the UnloadMode in VB6.
actually I had the same question a few days ago and I asked it in GotDotNet forums, I couldnt find the answer. But there is a way to do it. This is from MSDN: "If it is necessary to determine why the form is closing, you will need to create an overloaded version of the Closing event with custom code to determine the caller."
so there is a way but I dont know how to overload this thing the way it says it
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Sep 26th, 2002, 04:10 PM
#5
What MSDN article does that come from? I really miss that feature especially for some TrayIcon apps I have.
-
Sep 26th, 2002, 10:00 PM
#6
Thread Starter
New Member
i found out a way to get work. In the "Windows Form Designer generated code" the is a dispose function. i put my code there.
-
Sep 26th, 2002, 10:11 PM
#7
New Member
I am not sure but, I think this is what you are looking for. It uses the new class messagebox, the old msgbox is still there but it in the Microsoft.VisualBasic namespace. I try to use the SYSTEM namespace first you know onward and upward.
Anyway this works perfect, you can stop the form from closing. The old way was with a byref variable, but we are using objects now.
Private Sub frmMain_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Dim Response As DialogResult
Response = MessageBox.Show("Are you sure you want to Quit?", "Finishing", MsgBoxStyle.YesNo)
If Response = DialogResult.No Then e.Cancel = True
End Sub
A Jeepers point of view
Get In, Sit Down, Shut Up and Hold On!
-
Sep 26th, 2002, 10:16 PM
#8
Sleep mode
overloading
related to overloading
Private Sub form1_closing(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closing
Overloading lets a function vary its behavior based on its input arguments . vb.net will have multiple functions with the same name, but with different argument lists.
Private Sub form1_closing(ByVal sender As Integer , ByVal e As System.EventArgs) Handles MyBase.Closing (as an example)
Last edited by Pirate; Sep 26th, 2002 at 10:19 PM.
-
Sep 26th, 2002, 11:16 PM
#9
How do you get the OS or what not to tell you why the form is closing like the old UnloadMode. For instance was it the x close button in the corner of the form? Was it the Me.Close method in your code? Was it because the OS is shuting down? The last one is really the most important.
-
Sep 27th, 2002, 12:27 AM
#10
Originally posted by Edneeis
How do you get the OS or what not to tell you why the form is closing like the old UnloadMode. For instance was it the x close button in the corner of the form? Was it the Me.Close method in your code? Was it because the OS is shuting down? The last one is really the most important.
well take a lookie at these two, they dont help much, but maybe you can ask them a question so that they could help
http://www.gotdotnet.com/Community/M....aspx?id=40651
and (C# forums):
http://www.gotdotnet.com/Community/M....aspx?id=40717
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Sep 27th, 2002, 02:37 AM
#11
Well I can detect the X button close and the me.close (I think) but haven't found how to track the System closing. The way I have is somewhat hackish, its easy to implement but not the prettiest. I'll post it when I figure the last one out. Basically you can use the Application.AddMessageFilter to filter Window messages like subclassing. So then I just watch for the NCMouseDown event with wParam 20 which is the mousedown event for the form's close button. If I catch it then I don't forward it instead I call an alternate Closing event and pass the unloadmode in the eventargs.
-
Sep 30th, 2002, 12:24 PM
#12
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
|