2

I have a balloon popup (from a notifyIcon) in C# that works perfectly, unless there is a fullscreen application on the users monitor, such as a power point presentation. In that case, the popup doesn't show at all. However, once that app exits or is minimized (or the taskbar brought to front) you can see the balloon popups again.

Is there a way to make this popup show over all windows? Something like a form's "Top Most" setting? My code for the balloon is below if anyone needs it.

notifyIcon1.BalloonTipText = "Issue found!";
notifyIcon1.ShowBalloonTip(5000);

Thank you!

user1114503
  • 149
  • 2
  • 12
  • 9
    Maybe the person doing a Power Point Presentation doesn't want to see your balloons... – LarsTech Jun 10 '14 at 21:25
  • 1
    Everything can be done, but you should not to do try it. It is against the UI standards. - ATTN: A user who is against practices that makes windows look bad. – celerno Jun 10 '14 at 21:26
  • Which UI technology are you using? `Winforms`? – Yuval Itzchakov Jun 10 '14 at 21:27
  • possible duplicate of [How to make a window always stay on top in .Net?](http://stackoverflow.com/questions/683330/how-to-make-a-window-always-stay-on-top-in-net) – Yuval Itzchakov Jun 10 '14 at 21:29
  • some additional comments here http://stackoverflow.com/questions/23393846/ – bdimag Jun 10 '14 at 21:30
  • 4
    Don't you think that other window might be marked as "Always on top"? If that's the case, you're asking for "Always on top" to not always mean "Always on top" -- except at the same time, you're asking for *your own* "Always on top" to *always* mean "Always on top". There's a general principle you should keep in mind: you're not special. You don't get special treatment. The same rules that apply to everyone else's programs apply to your programs too. –  Jun 10 '14 at 21:39

2 Answers2

1

Since it doesn't look like there is a way to do it, here's what I did to do it. It's like a custom Balloon message, just set the form with no border, keep it small, and set TopMost = true. You'll need to adjust the WorkingArea.Right and WorkingArea.Bottom to fit your form size. Added the timer to auto kill the form after 10 seconds (will be shorter after I'm done testing everything) I didn't originally want to go this route, as I was hoping the balloon message provided a way to do thisenter image description here:

private void notifyUser_Load(object sender, EventArgs e)
    {
        var screen = Screen.FromPoint(this.Location);
        this.Location = new Point(screen.WorkingArea.Right - 250, screen.WorkingArea.Bottom - 85);
    }

    private void timer1_Tick(object sender, EventArgs e)
    {

        count++;
        if (count > 10)
        {
            count = 0;
            this.Close();
        }
    }

For everyone worried about the user not wanting to see it etc, this program is specifically created to monitor a bunch of other applications / settings / logs in Windows, and if there are errors, they will want to know. Power Points aren't actually run on these computers, that was just an example so everyone know what I meant. I'll make it "prettier" later.

user1114503
  • 149
  • 2
  • 12
1

It actually is possible. When your application (or another one) is running full screen, it also covers the taskbar and therefore the system tray, which prevents the balloon to show up. The trick is to give focus to the Windows system tray right before showing the notification. Here is how to do it.

  1. First you will need some p/invoke:
[DllImport("user32.dll")] static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")] static extern bool SetForegroundWindow(IntPtr hWnd);
  1. And then the actual trick:
SetForegroundWindow(FindWindow("Shell_TrayWnd", null));
  1. Finally your notification
notifyIcon1.visible = true;
notifyIcon1.ShowBalloonTip(5000);
Couitchy
  • 1,079
  • 10
  • 15