Solved

Hide default form buttons and start from system tray

Posted on 2012-03-28
6
309 Views
Last Modified: 2012-06-27
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
Comment
Question by:alfardan
  • 3
  • 2
6 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
ID: 37775358
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
 

Author Comment

by:alfardan
ID: 37775363
Where is this CreateParams property?

I'm using VS 2010
0
 

Author Comment

by:alfardan
ID: 37775366
Also, I don't want to disable the max button only, I want to set its visibility to false
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 53

Assisted Solution

by:Dhaest
Dhaest earned 500 total points
ID: 37775371
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
 
LVL 53

Expert Comment

by:Dhaest
ID: 37775377
>> Where is this CreateParams property?

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

Expert Comment

by:BuggyCoder
ID: 37775380
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Close form "before" open 3 40
Prevent call a sub/function several times when data bind to gridview 21 29
SQL LINE CONTINUATION ISSUE 12 31
Store results in vb.net 3 20
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question