472,961 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,961 software developers and data experts.

notify icon n balloon tip HELP urgent

i want to write a C# .net code to display a balloon in the task bar
i have used notifyicon class to get the icon in the task bar
then i have used Shell_NotifyIcon and NotifyIconData structure for
getting the balloon
So now i have an icon n a balloon in the task bar

But i wan tht when i click on the yellow windows balloon an event
should be fired
I know tht i have to use NIN_BALLOONUSERCLICK of Shell_NotifyIcon for
achieving this
but still i am not getting it exactly
i tried it but cudnt proceed
can anyone help me as to how to fire event on click of the ballon

Main class which displays icon and balloon code snippet:
private const Int32 NOTIFYICON_VERSION = 3;


public static extern System.Int32 Shell_NotifyIcon(NotifyCommand cmd,
ref NotifyIconData data);

public static extern System.UInt32 GetCurrentThreadId();

public delegate System.Int32 EnumThreadWndProc(System.IntPtr hWnd,
System.UInt32 lParam);

public static extern System.Int32 EnumThreadWindows(System.UInt32
threadId, EnumThreadWndProc callback, System.UInt32 param);

public static extern System.Int32 GetClassName(System.IntPtr hWnd,
System.Text.StringBuilder className, System.Int32 maxCount);

#region Structure NotifyIconData
public struct NotifyIconData
public System.UInt32 cbSize; // DWORD
public System.IntPtr hWnd; // HWND
public System.UInt32 uID; // UINT
public NotifyFlags uFlags; // UINT
public System.UInt32 uCallbackMessage; // UINT
public System.IntPtr hIcon; // HICON
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=128)]
public System.String szTip; // char[128]
public System.UInt32 dwState; // DWORD
public System.UInt32 dwStateMask; // DWORD
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=256)]
public System.String szInfo; // char[256]
public System.UInt32 uTimeoutOrVersion; // UINT
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=64)]
public System.String szInfoTitle; // char[64]
public System.UInt32 dwInfoFlags; // DWORD

#region ShowBalloon
/// <summary>
/// displays the taskbar balloon message
/// </summary>
/// <param name="uintIconID"></param>
/// <param name="strTitle"></param>
/// <param name="strText"></param>
/// <param name="uintTimeout"></param>
public void ShowBalloon(uint uintIconID, string strTitle, string
strText, uint uintTimeout)
bool blnVersionOk = false;
blnVersionOk = this.GetShell32VersionInfo() >= 5;
// get the current thread ID
uint uintThreadId = GetCurrentThreadId();

Type objType= m_objNotifyIcon.GetType();

IntPtr intPtrWindow =
((NativeWindow)objType.GetField("window",System.Re flection.BindingFlags.Instance
System.Reflection.BindingFlags.NonPublic).GetValue (m_objNotifyIcon)).Handle;
int intID
=(int)objType.GetField("id",System.Reflection.Bind ingFlags.Instance |
System.Reflection.BindingFlags.NonPublic).GetValue (m_objNotifyIcon);

// show the balloon
NotifyIconData objData = new NotifyIconData();
objData.cbSize =
(System.UInt32)System.Runtime.InteropServices.Mars hal.SizeOf(typeof(NotifyIconData));
objData.hWnd = intPtrWindow;
objData.uID = (UInt32)intID;
objData.uFlags = NotifyFlags.Info;
//objData.uTimeoutOrVersion =uintTimeout;
objData.uTimeoutOrVersion =NOTIFYICON_VERSION ;
objData.szInfo = strText;
objData.szInfoTitle = strTitle;
int q=Shell_NotifyIcon(NotifyCommand.SetVersion,ref objData);
int k=Shell_NotifyIcon(NotifyCommand.Modify, ref objData);
catch(Exception objException)
throw new ApplicationException(objException.Message);

#region enum
public enum NotifyCommand {Add = 0, Modify = 1, Delete = 2, SetFocus
= 3, SetVersion = 4}
public enum NotifyFlags {Message = 1, Icon = 2, Tip = 4, State = 8,
Info = 16, Guid = 32}
Form1 has notify icon which appears in task bar and its double click
event shows the ablloon

#region NotifyIcon_Click
private void NotifyIcon_Click(object sender, System.EventArgs e)

ShowBalloon(1, "Updates", "Updates Available", 15000);
catch(Exception objException)
throw new ApplicationException(objException.Message);


Nov 17 '05 #1
0 2495

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: jm | last post by:
Hi, I have a C# program that changes the notifyIcon during the program. What I have noticed is that sometimes when the program is over the old icon will still be in the system tray. But when i...
by: Rob | last post by:
I have an interesting problem with my Notify Icon. I cannot get it to display when I start a web service. I have no problems when I test the software on a Windows program. But the Icon will not...
by: Andrea V.F. | last post by:
I use the code below (VB.NET) to display a Popup balloon in the Tray Icon of my application. The balloon is displayed, but the timeout never happens and the balloon is always visible even if I...
by: Dave Booker | last post by:
I create a balloon tip in the system tray using: notify.ShowBalloonTip(10000, "Text", "More Text", ToolTipIcon.Info); After the time expires I want the icon to go away. The balloon disappears,...
by: Amongin Ewinyu | last post by:
Hi, I have an application that is controlled by a service. when the service starts, an icon is supposed to be placed in the system tray and this icon is then used to display a balloon...
by: Mike Eaton | last post by:
Hi there, I have an app whose structure is as follows: a module calls a custom application context containing a notify icon and associated context menu, which in turn acts upon an instance of...
by: DBC User | last post by:
I have a windows form and I added a notify icon. In there I have following 2 lines notifyIcon.ShowBaloonTip(1000,"test", msg, ToolTipIcon.Info); I stepped through the code and it executed...
by: Cylix | last post by:
I am going to make an application in monitor and do something on time. A part of it is an Notify icon(System Tray Icon), Which project type can I be used for Just showing the notify icon without...
by: mr t | last post by:
Hi guys, I have a notify Icon, but when I call showBallonTip, the balloon does not show. any reason why? here is my call: Me.NotMemberServ.ShowBalloonTip(5000, "New Member IDs", iCountNew & "...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.