Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • Last Modified:

Hide default form buttons and start from system tray

Hi

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?
0
alfardan
Asked:
alfardan
  • 3
  • 2
2 Solutions
 
DhaestCommented:
To disable the max-button and close-button (without interop):

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

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

I'm using VS 2010
0
 
alfardanAuthor Commented:
Also, I don't want to disable the max button only, I want to set its visibility to false
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
DhaestCommented:
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
0
 
DhaestCommented:
>> Where is this CreateParams property?

You need to paste this code into your form1.designer.vb
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

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