I try to minimize my form to system tray but when I do, the form disappears and the notification icon doesnt work :(
What am I doing wrong?
Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
If Me.WindowState = FormWindowState.Minimized Then
Me.Visible = False
NotifyIcon1.Visible = True
End If
End Sub
Private Sub NotifyIcon1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles NotifyIcon1.Dou开发者_运维问答bleClick, NotifyIcon1.BalloonTipClicked
Me.WindowState = FormWindowState.Normal
Me.Visible = True
NotifyIcon1.Visible = False
End Sub
I initialize NotificationIcon text, balloon tip and other stuff in the aspx page
That's in C# but the idea should be obvious :)
private void Form1_SizeChanged(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
notifyIcon1.Visible = true;
this.ShowInTaskbar = false;
this.Hide();
}
else
{
notifyIcon1.Visible = false;
}
}
void notifyIcon1_DoubleClick(object sender, EventArgs e)
{
notifyIcon1.Visible = false;
this.ShowInTaskbar = true;
this.Show();
this.WindowState = FormWindowState.Normal;
}
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
NotifyIcon1.Icon = Me.Icon
End Sub
In the tutorial it was not telling me to include Icon in the Form Load, that was the reason.
Problem solved! :)
精彩评论