System Tray Icon

runswithsizzors

Well-known member
Joined
May 11, 2005
Messages
70
Location
Northern Michigan
Programming Experience
5-10
System Tray Icon - Resolved

I was working with the system try icon (notifcation icon) and I was thinking is there any way to trap the minimize, maximize and the X in the top right of the form?
 
Last edited:
You can determine when a form is minimised and maximised using the Resize event. You can determine that a form is closing using the Closing event. If you want to know specifically that the control buttons were used for these operations then you would have to intercept the specific Windows messages. Is there a particular reason that you want to differentiate the use of those buttons from other methods of performing the same opeartions?
 
No there isn't any real reason I wanted to differentiate those. But what I was doing when the form was normal mode the system icon was hidden and when in minimized mode the icon was shown. I was using the 101 examples from microsoft and adding more to that project and trying to make theirs a little better. Thanks for the reply!
 
Here's the sort of code I usually use for that:
VB.NET:
    Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
		If Me.WindowState = FormWindowState.Minimized Then
			Me.ShowInTaskbar = False
			Me.NotifyIcon1.Visible = True
		Else
			Me.ShowInTaskbar = True
			Me.NotifyIcon1.Visible = False
		End If
	End Sub
 
Me.ShowInTaskbar = False

jmcilhinney said:
Here's the sort of code I usually use for that:
VB.NET:
    Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
        If Me.WindowState = FormWindowState.Minimized Then
            Me.ShowInTaskbar = False
            Me.NotifyIcon1.Visible = True
        Else
            Me.ShowInTaskbar = True
            Me.NotifyIcon1.Visible = False
        End If
    End Sub

Simple question I try this code, adn it works fine in one of my application. Now in another one when I minimize it, it does close my program. I notice that if comment

Me.ShowInTaskbar = False

then it will not close the application. Is there any reason why this happen or if any one knows how to fix this.

Thanx for any help.
 
jmcilhinney said:
There's no reason that that should cause your app to close that I can think of.

I understand that. I try it in two applications. In one works just fine, and in the other does the closing. Is there any other reason or maybe another control that my be causing that. Or maybe a setting?
 
Back
Top