Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Hide default form buttons and start from system tray

Posted on 2012-03-28
6
Medium Priority
?
316 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 2000 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 53

Assisted Solution

by:Dhaest
Dhaest earned 2000 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

Featured Post

Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

Question has a verified solution.

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

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

715 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