Search code examples
vb.netnotificationssystraytray

Win7 systray style popup


Hello guys I have an applcation that sets itself to 0 opacity on Form1_load which then changes to 1 when the user left clicks on the NotifyIcon. I would also like the form to center itself directy above the notifyicon like the Win7 speakers, power, ect popups.

What's the best way to do this?

Thanks


Solution

  • As others have mentioned; I wouldn't bother with .Opacity unless you are using values beyond 0 and 1. I believe it will be more clear (and more performant, but I'm speculating) to use .Show and .Hide.

    To center a form above the NotifyIcon in the System Try; you might want to just grabbing the mouse position and the screen size. Inside the NotifyIcon_Click event you could do...

    Dim xPos As Integer = MousePosition.X
    

    And center your form over that position. It won't technically be perfectly centered over the NotifyIcon - if you click on the left edge, it would be centered over the left edge. You can use .GetWorkingArea on the PrimaryScreen to get the height and position the Y value appropriately.