.NET Framework Bookmark and Share   
 index > .NET Base Class Library > Balloon Tip in System Tray shows behind all windows.
 

Balloon Tip in System Tray shows behind all windows.


Hi Tech Friends,

I am trying to write a small systray application which can show internet connectivity status. It works fine with balloon notification.
However, the balloon always shows on desktop behind task bar! How to set balloon always show in front?

Below is the sample code( excuse for pasting here. looks like code block paster does not work with IE8 properly):

---------------------------------------------------------------------------------------------------------

using

System;using System.Drawing;using System.Resources;using System.ComponentModel;using System.Windows.Forms;using System.Net.NetworkInformation;using System.Threading;

public class SystemTray : System.Windows.Forms.Form

{

private System.Windows.Forms.NotifyIcon WSNotifyIcon;

private System.ComponentModel.IContainer components;

private Icon mDirIcon = new Icon(typeof(SystemTray).Assembly.GetManifestResourceStream("InternetCheck.FLGUSA02.ICO"));

public bool ShowConnectedStatus = false;

public SystemTray()

{

//constructor for the form

InitializeComponent();

//keep the form hidden

this.Hide();

IntializeConnectionCheck();

}

/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose(bool disposing)

{

if (disposing)

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose(disposing);

}

#region

Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

this.components = new System.ComponentModel.Container();

this.WSNotifyIcon = new System.Windows.Forms.NotifyIcon(this.components);

this.TopMost = true;

//

// WSNotifyIcon

//

this.WSNotifyIcon.Text = "Connectivity Check";

this.WSNotifyIcon.Visible = true;

this.Visible = true;

//

// SysTray

//

this.AccessibleRole = System.Windows.Forms.AccessibleRole.None;

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(8, 7);

this.ControlBox = false;

this.Enabled = false;

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;

this.MaximizeBox = false;

this.MinimizeBox = false;

this.Name = "SystemTray";

this.Opacity = 50;

this.ShowInTaskbar = false;

this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;

}

#endregion

/// <summary>

/// The main entry point for the application.

/// </summary>

[

STAThread]

static void Main()

{

Application.Run(new SystemTray());}

public bool IsConnectionAvailable()

{

//create an instance of the System.Net.NetworkInformation Namespace

Ping ping = new Ping();

//Create an instance of the PingReply object from the same Namespace

PingReply reply;

//int variable to hold # of pings not successful

try
{

//use the Send Method of the Ping object to send the

//Ping request

reply = ping.Send(

"64.233.169.103", 10000);

//now we check the status, looking for,

//of course a Success status

if (reply.Status != IPStatus.Success)

{

//now valid ping so increment

return false;}

else

{

return true;}

}

catch (Exception err)
{
return false;
}
}

private void IntializeConnectionCheck()
{
WSNotifyIcon.Icon = mDirIcon;
WSNotifyIcon.Visible =
true;
WSNotifyIcon.BalloonTipTitle =
"Check Connectivity";

if (!IsConnectionAvailable()){
WSNotifyIcon.BalloonTipText =
"No Internet Connection !";
WSNotifyIcon.ShowBalloonTip(10000);
ShowConnectedStatus =
true;

}

else if(ShowConnectedStatus){

WSNotifyIcon.BalloonTipText =

"Now Connected !";
WSNotifyIcon.ShowBalloonTip(10000);
ShowConnectedStatus =
false;

}

Thread.Sleep(10000);
IntializeConnectionCheck();

}

}

Jai Mallesh Babu

Hello Jai

On what operating system did you see this problem?

The .NET NotifyIcon component internally calls the native API Shell_NotifyIcon. There was a known issue of Shell_NotifyIconin Windows XP that Windows tooltips and NotifyIcons show behind Taskbar.
http://support.microsoft.com/kb/912650/en-us
A community member also blogged this issue:
http://www.raymond.cc/blog/archives/2007/12/08/fix-windows-tooltips-showing-behind-taskbar/
Therefore, the issue in this thread may not be related to IE8.
As far as I know, the problem was fixed in Windows Vista and the later operating systems. In Windows XP, there are some third party free solutions like http://neosmart.net/dl.php?id=10.

This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

Regards
Jialiang Ge


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Jialiang Ge [MSFT]
Thank you,
I will check the article and get back.

However, operating system is: Windows Server 2003

Regards,
Jai
Jai Mallesh Babu
Server 2003 is basically equivalent to WinXP
Server 2008 is basically equivalent to Win Vista
Server 2008 R2 is basically equivalent to Win7
(rest of form content)
ImDbg

You can use google to search for other answers

Custom Search

More Threads

• How do you get the list of active root objects?
• How To Remove all event handlers for an Event (Unwire, Unsubscribe)
• Cannot open Service Control Manager on computer ''. This operation might require other privileges.
• BadImageFormatException while loading assembly from embedded resource
• Databinding change between FW 1.1 and 2.0?
• Reflection for Boxed Primitives
• Appdomain Assembly Load
• Zip the file in C# .net 2.0 windows application
• Singleton in baseclass?
• adding windows xp visual style to the vb.net forms