How to minimize to system tray ? VS 2003

P

pamelafluente

Hello guys,

I have done a small utility and would like that an image be displayed
on the the windows tray (on bottom-right of the screen).

Also I would like that when one clicks on X (close) the application be
minimized and only the tray icon be visible.
When one clicks on the tray icon the application shoud return to its
normal status (normal/maximized, depending how it was when was
minimized).

Any suggestion or help on how to do that?
Any sample would be much apprecciated!

Thank you very much in advance!

-Pam
 
C

cbrown

Add a notify Icon to your form and capture the Forms Minimize event.
When a user minimizes a form Hide it from the task bar.

I have some code in a minute for you.
 
C

cbrown

Private Sub Main_SizeChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.SizeChanged
If Me.WindowState = FormWindowState.Minimized Then
Me.ShowInTaskbar = False
End If
End Sub
 
F

Federico G. Babelis

You need to add a NotifyIcon Control to your VB Form

Then, use the followig code as example:

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Private Sub RestoreWindow()
Me.Show()

Me.WindowState = FormWindowState.Normal

Me.Focus()

End Sub

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Private Sub f_<SomeFormName>_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Resize

If Me.WindowState = FormWindowState.Minimized Then

Me.Hide()

endif

End Sub

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Private Sub NotifyIconMain_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles NotifyIconMain.DoubleClick

RestoreWindow()

End Sub
 
P

pamelafluente

THANKS!! very kind of you!

What do you mean by "Add a notify Icon to your form" (sorry for the
ignorance!) ?

-Pam
 
P

pamelafluente

Ah OK. I found the Notify icon!

Thank you very VERY much: you both are angels !!

-Pam
 

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