I was to hide my startup form because I only want to display my tray icon. Any ideas how to do this?
You can add a minimize event on load, if that your program is set to minimize to system tray!
Or you can add Me.Opacity = 0(Me.Opacity = 1 when clicked on systray icon again) on load, and then hide the taskbar button!
1. // IDE: set opacity to 0
2. // IDE: add a timer to your form
3. timer.Enabled = true //enable the timer on form.Load event
4. me.hide() // the timer.Tick even hide form
5. me.opacity = 1 // the timer.Tick make form opacity back to normal
6. me.show() // yourNotifyIcon.click event
Why not just:
this.Visible = false;
this.ShowInTaskbar = false;
Hi guys,
Interesting thread this.
The method that i've implemented to do this was through the use of this code:
#Region "Taskbar Icon"
REM TASKBAR ICON
Private Sub NotifyIcon1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDown
If Me.WindowState = FormWindowState.Normal Then
Me.WindowState = FormWindowState.Minimized
Else
Me.WindowState = FormWindowState.Normal
End If
End Sub
#End Region
On the form properties I also made sure that it didnt have appear in the task bar, nor have minimise/maximise/quit buttons..
However, to get to my question - i've tried using this opacity function to produce a 'fade in/out' type affair.
However, even though the code itself is correct, on running it, it'll produce the error message:
An unhandled exception of type 'System.NullReferenceException' occurred in Agility.exe
Additional information: Object reference not set to an instance of an object.
So..any takers to tell me whats going on?
All i want is for it to fade in/out on the system tray button click given if it is already in view or not.
Thanks
prabably those code are running when no from active under your "Me"
try
Me.Opacity() -= 0.1
a tip to fading effect:
you should do your fade codes with threading method rather than just a simple loop.
for example, you can have a timer with interval of 100ms, every time the timer tick, you reduce the opacity by 0.1, until it reaches 0 (totally invisible) or whatever you want.
And to make it "solid" you do it with the timer again but isntead of reduce opacity, you increase it, until it reaches 1
And of course, if you want, you can create a separate thread and just run the loop with that second thread, however I found the timer method is easier.
thanks for the reply.
I found that using the timer was going to be the safest bet. To solve the problem, dont have your form minimised on startup folks :)
Yes, believe it or not, that was the answer...
I believe you, if your form is minimised, I guess that will make it not 'Me.ActiveForm'
This works just as well easy to add simple code.
Private Sub mnuAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAbout.Click
Dim frmAboutAs New frmAbout
frmAbout.ShowInTaskbar = False
frmAbout.ShowDialog()
frmAbout.Dispose()
End Sub
This works just as well easy to add simple code.
Private Sub mnuAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAbout.Click
Dim frmAboutAs New frmAbout
frmAbout.ShowInTaskbar = False
frmAbout.ShowDialog()
frmAbout.Dispose()
End Sub
1. You should look at the date of the post. This topic is more than 5 years old.
2. If you are going to post in a 5 year old topic, atleast post code that will actually accomplish what the OP asked for. Your code simply does not show a taskbar element for the form. The form is still visible which is not what the OP wanted.
Well, i stumbled upon this solution and finally made it to this:
Put a timer-object and a notify-icon on the master page:
Private Sub Master_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Opacity = 0
Timer1.Enabled = True
Me.ShowInTaskbar = False
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Opacity = 1
Me.Hide()
Timer1.Stop()
End Sub
don't forget the timer1.stop() because your form will disappear again :eek: :eek:
Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
Me.Show()
End Sub
This should do the trick of hiding the main form, and show no form on the taskbar en raise the form back on double clicking the notifier icon.