Minimize Form to Systray

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

All,

I have been trying to come up with a work around for the default form
minimization process in .net. Currently, when you minimize a form it
animates the minimization to the bottom left. This is fine, unless you
are trying to minimize to the systray. Below is a snippet of code I
wrote (copied from Kollen) but I must be doing something wrong cause I
a get is a hidden form and no minimization animation. Any help would
be appreciated.

Private Sub AnimateToSysTray()

Me.Hide()
'Animate hiding to the system tray
Dim _rect As Rectangle = Me.DesktopBounds
Dim _from As RECT
Dim _to As RECT


With _from
.Top = _rect.Top
.Left = _rect.Left
.Bottom = _rect.Bottom
.Right = _rect.Right
End With

Dim hWndP As System.IntPtr = FindWindow("Shell_TrayWnd",
vbNullString)
Dim hWndC As System.IntPtr = FindWindowEx(hWndP,
System.IntPtr.Zero, "TrayNotifyWnd", vbNullString)
If Not (IntPtr.Zero.Equals(hWndC)) Then
GetWindowRect(hWndC, _to)

Else
' Default to bottom right of screen if something goes wrong

_to.Left = SystemInformation.VirtualScreen.Right - 118
_to.Top = SystemInformation.VirtualScreen.Bottom - 30
_to.Right = SystemInformation.VirtualScreen.Right
_to.Bottom = SystemInformation.VirtualScreen.Bottom
End If
DrawAnimatedRects(Me.Handle, IDANI_CAPTION, _from, _to)

End Sub


-b
 
Hi Bob,
did you add to your form a notifyIcon control ? cos this control handels the
systray for .NET.
hope that helps
 
Yes...got all that working OK..my systray icon appears and works great
but when I minimize the form to go to systray, the animation MS uses
always show the form going to the bottom lett and not the bottom right.
 
Back
Top