• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 322
  • Last Modified:

Hide default form buttons and start from system tray


I want my windows form to hide the Close and Maximize buttons, and for this form to be called from the system tray and when clicking on its Minimize button then to take it back to the system tray

How do I do so?
  • 3
  • 2
2 Solutions
To disable the max-button and close-button (without interop):

Set MaximizeButton (maximizebox) to False and edit CreateParams as follows:

Protected Overrides ReadOnly Property CreateParams() As CreateParams
Dim cp As CreateParams = MyBase.CreateParams
Const CS_DBLCLKS As Integer = &H8
Const CS_NOCLOSE As Integer = &H200
Return cp
End Get
End Property
alfardanAuthor Commented:
Where is this CreateParams property?

I'm using VS 2010
alfardanAuthor Commented:
Also, I don't want to disable the max button only, I want to set its visibility to false
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Minimise To System Tray in VB.Net
Here's how to make your VB.Net form minimise to the system tray (next to the clock) instead of the task bar.
Add a NotifyIcon to your form by double-clicking on it in the Toolbox. Call in ni. Change its Icon property to the same icon you used for your form.
In your form's Form.Load function, add:
ni.Visible = False
                  Create/modify the SizeChanged event on your form like so:
Private Sub Form_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) _
      Handles MyBase.SizeChanged

      If Me.WindowState = FormWindowState.Minimized Then
            Me.WindowState = FormWindowState.Minimized
            Me.Visible = False
            Me.ni.Visible = True
      End If

End Sub
                  Create a click event for your NotifyIcon like:
Private Sub ni_Click(ByVal sender As Object, ByVal e As System.EventArgs) _
      Handles ni.Click

      Me.Visible = True
      Me.WindowState = FormWindowState.Normal
      Me.ni.Visible = False

End Sub

Source: http://www.jack-frost.co.uk/vb_net_minimise_system_tray.html
>> Where is this CreateParams property?

You need to paste this code into your form1.designer.vb
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now