NotifyIcon.ShowBalloonTip: alcune note

Tramite il componente NotifyIcon è possibile visualizzare dei BallonTip di notifica all’utente utilizzando il metodo ShowBalloonTip.

image

Vis sono però alcuni comportamenti che potrebbero non essere quelli attesi:

  1. A seconda del sistema operativo il BallonTip può rimanere visibile da un minimo di 10 secondi fino ad un massimo di 30 secondi a seconda del sistema operativo. Valori maggiori o minori di timeout verranno ignorati.
    Dalla documentazione: “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”
  2. Se non si verificano eventi di mouse o di tastiera il timeout non viene conteggiato e il BallonTip viene visualizzato a tempo interminato.
    Dalla documentazione: “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.”
  3. E’ possibile visualizzare un solo BallonTip alla volta se l’applicazione visualizza un secondo BallonTip il primo verrà chiuso indipendentemente dal timeout. Se invece un secondo BallonTip viene visualizzato da un’applicazione diversa il primo BallonTip scomparirà solo quando sarà scaduto il timeout, quindi verrà visualizzato il secondo BallonTip.
    Dalla documentazione: “Only one balloon tip can display on the taskbar at a time. Attempting to display a balloon tip when one is currently displayed on the taskbar causes the timeout value to be ignored. The behavior is slightly different depending on the operating system and whether the balloon tip is from another, or the same, application. When the second balloon tip is from another application, the first balloon tip will display for the minimum timeout value before the second appears, regardless of the value of timeout. In most cases, if the balloon tips are from the same application, the first balloon tip immediately closes when another call to the ShowBalloonTip method is made. In some cases the second balloon will open on top of the first balloon.”
  4. Quando l’applicazione si chiude deve nascondere la NotifyIcon impostando la proprietà Visible a False in caso contrario la NotifyIcon  continuerà ad essere visibile nella Tray anche dopo la chiusura dell’applicazione (fino a quando il mouse non si posizionerà sopra la NotifyIcon) e nel caso sia visualizzato un BallonTip questo continuerà ad essere visibile anche dopo l’arresto dell’applicazione.
  5. Per nascondere un BallonTip immediatamente è possibile impostare a False la proprietà Visible della NotifyIcon e reimpostarlo subito dopo a True.

Per disabilitare i BallonTip a livello utente è possibile utilizzare la chiave di registro EnableBalloonTips in HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced.

Per disabilitare i BallonTip a livello di sistema è possibile utilizzare la chiave di registro EnableBalloonTips in HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced.

A riguardo si vedano How do I disable balloon tips in the notification area in Windows XP or Vista? e Suppressing Balloon Pop-Ups.

 

Per ulteriori informazioni si vedano: