0

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

uiandform
  • 3
  • 1

1 Answers1

0

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.

Rob P.
  • 14,921
  • 14
  • 73
  • 109
  • I have tried using .hide and .show but `Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Hide() 'Opacity = 0 End Sub` doesn't want to work for me – uiandform May 09 '11 at 21:21
  • That's because `Load` is fired before the form is shown. Handle `Shown` instead. – SLaks May 10 '11 at 01:23
  • Ahh okay, Dim xPos As Integer = MousePosition.X also worked great, thank you. – uiandform May 11 '11 at 06:33