Minimize Form to Systray

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
 
N

Nassos

Hi Bob,
did you add to your form a notifyIcon control ? cos this control handels the
systray for .NET.
hope that helps
 
B

Bob

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top