jace808 Posted August 15, 2003 Posted August 15, 2003 I have a class with a Shared Sub Main() that starts things off. It shows a menu then when the user clicks the exit button it "should" minimize to system tray. It does minimize to system tray, but as soon as it does the app closes too. This is basically what I have in the Sub Main(). Public Class Main Public Shared Sub Main() Dim frmMenu As New VATMenu() Application.Run(frmMenu) End Sub End Class I was going to do a search on this topic, but didn't really know what to search for. Basically I need to know how to keep my app alive when it gets to the End Sub. TIA. Quote
*Experts* mutant Posted August 15, 2003 *Experts* Posted August 15, 2003 You cant keep it running if it gets to End Sub. Are you modiyfing the Closing event of your from so it minimizes when closing as you say? Quote
jace808 Posted August 15, 2003 Author Posted August 15, 2003 You cant keep it running if it gets to End Sub. Are you modiyfing the Closing event of your from so it minizes when closing as you say? Yes I am on the frmMenu_Closing. I believe that is where it closing the project at. Here is the code I have for that procedure. Private Sub me_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing Dim frm1 As New Form1() xLoc = Me.Location.X yLoc = Me.Location.Y exitQuestion = MsgBox("Are you sure you want to exit the VAT's menu?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirm Exit") If exitQuestion = vbNo Then Me.Location = New Point(xLoc, yLoc) Me.StartPosition = FormStartPosition.Manual Me.Show() ElseIf exitQuestion = vbYes Then exitQuestion = MsgBox("Do you want to minimize menu to the system tray?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Minimize to Tray") If exitQuestion = vbNo Then frm1 = New Form1() Me.Visible = False frm1.RemoveIcon() frm1.Visible = False frm1.RemoveIcon() Else Me.Show() End If End If End Sub frm1 is of course the tray icon. Quote
*Experts* mutant Posted August 15, 2003 *Experts* Posted August 15, 2003 You need to cancel the closing of the form, even though you put code in the event it still will close after executing that code unless you stop it: e.Cancel = True This goes into your closing event wherever you want to stop the form from closing. Quote
jace808 Posted August 15, 2003 Author Posted August 15, 2003 Beautiful... that did the trick. Thanks. :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.