Starting the program in the track



  • How do we launch the program right in the track? I've done a turn on the "Stop" button:

    private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
    {
        this.Show();
        this.WindowState = FormWindowState.Normal;
        notifyIcon1.Visible = false;
    }
    

    private void Form1_Resize(object sender, EventArgs e)
    {
    if (this.WindowState == FormWindowState.Minimized)
    {
    this.Hide();
    notifyIcon1.Visible = true;
    }
    }

    How do we arrange for the application to appear in a three-way launch without display of shape on the screen?



  • It's mainly necessary to call. Application.Run()without giving the uniform as a parameter.

    If you want to have an icon in three, modify the method. Main (Context menu, optical):

    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
    
    var form = new Form1();
    
    using (NotifyIcon icon = new NotifyIcon())
    {
        icon.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
        icon.ContextMenu = new ContextMenu(
            new []
            {
                new MenuItem("Show form", (s, e) => form.Show()),
                new MenuItem("Hide form", (s, e) => form.Hide()),
                new MenuItem("Exit", (s, e) => Application.Exit()),
            });
        icon.Visible = true;
    
        Application.Run();
        icon.Visible = false;
    }
    

    }

    https://stackoverflow.com/a/1617821/1985167




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2