How to have an invisible start up form?

前端 未结 7 2097
眼角桃花
眼角桃花 2020-12-17 16:43

I have an application that is a part of a solution of projects. In this project I would like for it to start up form to be invisible, but still have a notification icon in t

7条回答
  •  眼角桃花
    2020-12-17 17:22

    Here is another way that I've found to do this.

    Set the form properties with

    ShowInTaskbar = False
    

    Then in the form's constructor add

    WindowState = FormWindowState.Minimized
    

    This is very easy to implement and works with no flicker. In my case I also use a NotifyIcon to access the program from the notification tray and just set

    WindowState = FormWindowState.Normal
    Show()
    BringToFront()
    

    In the Notify_MouseClick event handler.

    To hide the form again after displaying it, just minimizing again doesn't quite do the job. In my case I use the Form_Closing event and just hide the form.

    Hide()
    

提交回复
热议问题