Home All Groups Group Topic Archive Search About

How to minimize to system tray ? VS 2003

Author
17 Jan 2006 7:01 PM
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

Author
17 Jan 2006 7:07 PM
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.
Author
17 Jan 2006 7:09 PM
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
Author
17 Jan 2006 7:11 PM
pamelafluente
THANKS!! very kind of you!

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

-Pam
Author
17 Jan 2006 7:09 PM
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

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



<pamelaflue***@libero.it> wrote in message
Show quoteHide quote
news:1137524398.196231.50120@g14g2000cwa.googlegroups.com...
> 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
>
Author
17 Jan 2006 7:21 PM
pamelafluente
Ah OK. I found the Notify icon!

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

-Pam