Solved

Hide default form buttons and start from system tray

Posted on 2012-03-28
6
311 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Please explain purpose of GZIP 4 56
transition to visual .net from vb6 5 57
C# XML Get Values 4 33
How do I copy a form and rename it in VS2015 2 19
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

685 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