Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make visible baloonTipText until it is clicked

I have a NotifyIcon in my program which displays a baloon tip in the taskbar. I wrote code as

notifyIcon1.Icon = new Icon(SystemIcons.Application, 40, 40);
notifyIcon1.Visible = true;
notifyIcon1.Text = "Test Notify Icon Demo";
notifyIcon1.BalloonTipText =count+ " Alerts";
notifyIcon1.BalloonTipIcon = ToolTipIcon.Info;
notifyIcon1.BalloonTipTitle = "Alert!";
notifyIcon1.ShowBalloonTip(999999999);

The baloon tip is invisible after the set time (999999999). But I want to show the baloon tip until it is clicked as I have baloontipclicked event.

How to make baloontip visible forever?

like image 402
sushma Avatar asked Sep 17 '11 07:09

sushma


2 Answers

from MSDN:

Minimum and maximum timeout values are enforced by the operating system and are typically 10 and 30 seconds, respectively, however this can vary depending on the operating system. Timeout values that are too large or too small are adjusted to the appropriate minimum or maximum value. In addition, if the user does not appear to be using the computer (no keyboard or mouse events are occurring) then the system does not count this time towards the timeout.

it seems not be possible to override the maximum timeout (eventually adjusted by Windows and limited to 30 seconds even if you specify a longer one) so the Notification will fade away, will not wait for you to click on it after 2 minutes.

if you want to really have a different behavior you should probably use something else, other objects or simulate something similar with forms where you have the full control on the behavior and you can show, hide and close as you wish from your code.

like image 101
Davide Piras Avatar answered Nov 03 '22 01:11

Davide Piras


You can show it again if it hasn't been clicked. You have the close event (BalloonTipClosed), if user hasn't ckicked it just show it again.

private void ShowBalloonTip(int minutes) {
    notifyIcon.BalloonTipIcon = ToolTipIcon.Error;
    notifyIcon.BalloonTipText = "Text";
    notifyIcon.BalloonTipTitle = "Title";
    notifyIcon.ShowBalloonTip(minutes* 60 * 1000);
    m_showUntil = DateTime.Now.AddMinutes(minutes);
}


private void notifyIcon_BalloonTipClosed(object sender, EventArgs e) {
    if (m_showUntil > DateTime.Now)
        notifyIcon.ShowBalloonTip(60 * 1000);
}
private void notifyIcon_BalloonTipClicked(object sender, EventArgs e) {
    m_showUntil = DateTime.MinValue;
    (..)
}
like image 45
Kalay Avatar answered Nov 03 '22 01:11

Kalay