open a form with only systray icon

Hello, how do i open a form so the form does not show and only an icon appears in systray I know how to make the icon but everytime I do this the form appears. I want to make the form only appear when I right click on the icon and say "appear". Thanks!



Answer this question

open a form with only systray icon

  • Scott Masters

    I think what you are looking for is this. Do a combination of the stuff below and I am sure you will get it working.

    'to hide the icon in systray:
    Private systray As New NotifyIcon()
    systray.Visible = False

    'to show the icon in systray:
    Private systray As New NotifyIcon()
    systray.Visible = true

    'to hide just the form

    me.hide()
    me.opacity=0
    Me.ShowInTaskbar = true

    'to show form
    me.show
    me.opacity=100
    Me.ShowInTaskbar = False



    I hope this helps.

  • soanfu

    you can hide the form, then when the user clicks on the appropriate menu item (Context item) in the systray, just show the form

  • Jon-12345

    it won't work on the load form event unfortunately. I guess one way would be to try to using perhaps a timer to hide the form, so every second or something, it will hide the form if its visible but indicate as a global value to actually show the form or not when the user requests to show the form.

    something like:

    //global:

    Dim IsUserRequest as Boolean = false

    'timer tick event:

    if Me.Visible AND Me.IsUserRequest = false then

    Me.Hide()

    end if



  • tiomeg

    Hi,

    I have the same problem that u have.Can you please tell me the procedure u followed.

    First of all my Problem is :

    I have only one form but im using sc_minimize if I set showintaskbar to false it wont work.But i dont want to display my application in takbar.I want to display in systray.

    Than you.


  • Duncan Woods

    Right, my apologies. What I am wanting to do..

    1. Application executes and user clicks on a button that launches a new form. First form dissapears.
    2. Form 2 does not appear and only an icon in systray appears. Nothing shows in the taskbar.
    3. Upon rightclicking on icon contextmenu appears. user selects "show".
    4. form appears and Icon is still available in systray.

    This all works properly for me however upon initially executing the second window (the one that is supposed to only show an icon in the systray) I have the icon appear and the form is fully minimized in the taskbar (where I dont want it shown at all).

    Thanks!

  • Fabio Pagano

    i donot know this is the right techique or not.

    you can set the form's opaque perporty to 0 and showintaskbar perporty to false at design time. and when user click on this system try then you set the opacity to 100 and showintaskbar to true. this way way you can achive this.



  • Frame

    I have tried to hide the form (frm.Hide()) but cannot hide it. can you told me where should i use it to hide the form.

  • ShadowOfTheBeast

    well you place it wherever you are going to hide it! Actually it should be :

    Me.Hide()

    to hide the current form. To show it:

    Me.Show()



  • K.Kong

    You seem to be asking for two different things:

    Initially: "how do i open a form so the form does not show and only an icon appears in systray"

    but in the post above: "it will hide form and NOT show in taskbar (Exactly what I want from the beginning):"

    It might be helpful if you would just recap exactly on the spec you want, line by line, e.g

    1. User clicks on ...

    2. Form instance is created but not shown

    3. However there will / will not be an icon in the systray

    ' etc


  • NBA

    Well I can get the form to hide on load but in the taskbar the icon is still there. I accomplish this by:

    (page load)

    me.hide()

    Me.opacity = 0

    me.visible = false

    me.showintaskbar = false 'doesnt seem to work

    But if I right click and select the option from the contextmenu to sho the form I use:

    me.opacity = 100

    me.visible = true

    me.showintaskbar = true

    If I have an option on the form once it is show to the user that says close, it will hide form and NOT show in taskbar (Exactly what I want from the beginning):

    me.hide() 'I hae his in the page load...

    So I need to do this using a timer That doesnt sound right.


  • Jon Braganza

    I figured it out.. it was just a small bug:

    code on first form is:
    Private m_TheForm As New secondform
    Private systray As New NotifyIcon()

    m_TheForm.Close()
    m_TheForm.Hide() 'MISSING LINE
    systray.Visible = False

    code on second form is:
    Me.Hide()
    Me.Visible = False
    Me.Opacity = 0
    Me.ShowInTaskbar = False

    without the line (MISSING LINE), the icon was still appearing in the taskbar. I really appreciate all of the help!

  • rmgjohnes

    ok,

    i have tried to hide the same way in the load method of the form. but it will not hide the form. in which event i will use it.

      

     



  • open a form with only systray icon