views:

161

answers:

2

In the application I am working with, if the user changes the value in a cell that is say positive to negative and the value is supposed to be positive at all times, the application forces the positive value. Right now, when this happens there is no alert shown to the user.

I would like to show a little unobtrusive alert, like the one that shows up when a new mail arrives in outlook, or something similar, so that the user can be alerted that the application did something on her behalf.

I tried using the NotifyIcon class to do this. But the problem with that class seems to be that the timeout on it doesn't work as expected. I want to show this alert for not more than 2s and the BallonTipText lasts for longer than 10s.

Is there a .NET class for this purpose? If not, is there an alternate way to do something like this?

+2  A: 

Using a notification icon for this case seems wrong to me. The user's attention is, when entering something into a cell, on the cell. If you display the notification on the lower right of the screen the user is very likely to miss it, or worse, it disrupts his work flow.

You might instead consider adding a balloon tip to the cell the user is editing. Kinda like the balloon tip Windows Explorer is showing on Vista and Windows 7 on renaming a file when you try entering a character that is disallowed in file names:

Joey
How would you create that balloon tip?
Svish
I have no idea. That was just from a UX perspective how you could improve the interaction. But you probably would have to go down th P/Invoke route for that.
Joey
Ajax is great for user feedback. To create tool tips / balloons, you could test this plugin: http://jquery.bassistance.de/tooltip/demo/
Steven
Ajax for a desktop application? I doubt it :)
Joey
I tried doing this using the ToolTip.Show method. But it doesn't work. Has anyone managed doing this?
tsps
A: 

I have had this problem in the past. I gather that the timeout problem is because the operating system fixes a minimum value of 10 seconds and a maximum value of 30 seconds (or something like that).Edit Oh and this doesn't include time that a user is idle.Edit

I have used the following code in the past to get around this.

Just to clarify Declare a public variable, say called ballonTipActive with a value of 0.

Insert a timer control disabled with 100ms delay and create an event from BalloonTipShown from the notifyicon control.

Then

private void ptNotifyIcon_BalloonTipShown(object sender, EventArgs e)
{
    timer1.Enabled = true;
    balloonTipActive = 0;
}

private void timer1_Tick(object sender, EventArgs e)
{

   balloonTipActive++;

   if (balloonTipActive == 40)
   {
     ptNotifyIcon.Visible = false;
     ptNotifyIcon.Visible = true;
     balloonTipActive = 0;
     timer1.Enabled = false;
   }
}

Setting the visible property to false then true gets rid of the balloon.

ChrisBD
Indeed this seems to be the common workaround, but keep in mind the icon will "jump" to the first tray position after the false/true setting
ohadsc