有没有人知道为什么当我运行程序时,单击任务栏项打开小文本输入区域,图标一旦到达就消失了!
非常感谢
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace systemTray
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
this.Visible = false;
}
private void Form1_Resize(object sender, System.EventArgs e)
{
if (FormWindowState.Minimized == WindowState)
{
Hide();
}
}
private void notifyIcon1_DoubleClick(object sender, System.EventArgs e)
{
var screen = Screen.PrimaryScreen;
this.Left = screen.WorkingArea.Right - this.Width;
this.Top = screen.WorkingArea.Bottom - this.Height;
Application.Run();
}
private void searchToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void quitToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
}
}
编辑:我不确定这是否有帮助,但是为了使应用程序不打开表单我改变了主要方法
Application.run(new form1())
到
new form1()
答案 0 :(得分:1)
Application.Run用于运行Windows窗体应用程序
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
当您删除行Application.Run(new Form1());
时,您的应用程序刚刚启动并调用Main()
,然后关闭它,因为它已完成它的工作。
问题是您删除Application.Run(new Form1());
??