Results 1 to 6 of 6

Thread: Start application minimize in system tray

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    214

    Start application minimize in system tray

    Hi !
    I've created one project where I want to start application directly minimize in system tray,it is there but I can see it also in taskbar.
    this is the code , and also project is attached

    Thanks !



    vb.net Code:
    1. Public Class frmMain
    2.  
    3.     Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    4.         Select Case e.CloseReason
    5.             Case CloseReason.ApplicationExitCall
    6.                 'The user perfromed an action that caused your code to call Application.Exit.
    7.                 'You could go either way here but I'd suggest that you shouldn't be calling Application.Exit
    8.                 'if you don't actually want the application to exit.  In that case close the main form instead.
    9.                 e.Cancel = False
    10.             Case CloseReason.FormOwnerClosing
    11.                 'This form is a modeless dialogue, which you shouldn't be minimising to the system tray anyway.
    12.                 e.Cancel = False
    13.             Case CloseReason.MdiFormClosing
    14.                 'This form is an MDI child form, which you shouldn't be minimising to the system tray anyway.
    15.                 e.Cancel = False
    16.             Case CloseReason.None
    17.                 'If the reason can't be determined then something funky is going on so I'd suggest you let the form close.
    18.                 e.Cancel = False
    19.             Case CloseReason.TaskManagerClosing
    20.                 'The user pressed the End Task button on the Applications tab (NOT the Processes tab) of the Task Manager.
    21.                 'You could go either way here too.  It really depends on your app and if you don't want the user to be able to exit
    22.                 'this way.  I'd suggest letting the form close but there would definitely be legitimate reasons for preventing it.
    23.                 e.Cancel = False
    24.             Case CloseReason.UserClosing
    25.                 'The user clicked the Close button on the title bar, pressed Alt+F4, selected Close from the
    26.                 'system menu or performed some action that caused your code to call the form's Close method.
    27.                 'Don't let the form close.
    28.                 e.Cancel = True
    29.                 Me.Visible = False
    30.                 ' Me.Hide()
    31.                 Me.ntfyI.Visible = True
    32.                 ' Me.ntfyI.ShowBalloonTip(1000)
    33.             Case CloseReason.WindowsShutDown
    34.                 'Windows is shutting down.
    35.                 'Definitely let the form close or you'll prevent Windows shutting down normally.
    36.                 e.Cancel = False
    37.         End Select
    38.  
    39.     End Sub
    40.     Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
    41.         Application.Exit()
    42.     End Sub
    43.  
    44.  
    45.     Private Sub ntfyI_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ntfyI.MouseDoubleClick
    46.         Me.WindowState = FormWindowState.Normal
    47.         Me.Visible = True
    48.         Me.ntfyI.Visible = False
    49.  
    50.     End Sub
    51.  
    52.     Private Sub cmbExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbExit.Click
    53.         Application.Exit()
    54.     End Sub
    55.  
    56.     Private Sub frmMain_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Move
    57.         If Me.WindowState = FormWindowState.Minimized Then
    58.             Me.Visible = False
    59.             Me.ntfyI.Visible = True
    60.  
    61.         End If
    62.  
    63.     End Sub
    64.  
    65. End Class
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width