Monday, 29 November 2010

Minimise VB.net app to the Notify Area on startup


It’s often desireable to create applications which startup in the Notify Area (or System Tray as it’s sometimes referred to).

The most obvious way to achieve this, one would think, would be to simply set the “Visible” Property of the main form in it’s Load Event. However, as this isn’t possible we have to use a work around.

The simplest method is to set the Visible Property asynchronously using a Delegate…

Public Delegate Sub InvokeByDelegate()


’ Hide Form

Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As  System.EventArgs) Handles MyBase.Load

Me.BeginInvoke(New InvokeByDelegate(AddressOf Me.HideForm)) ‘Invoke the Hide Form Routine Asynchronously

End Sub


’ Hide the Main Form

Private Sub HideForm()

Me.Visible = False

End Sub

No comments:

Post a Comment