就是我想实现一个像酷狗一样的功能,单击关闭按钮时不是关闭而是把应用程序最小化到桌面
解决方案 »
- 图片缓存的问题
- 查询出来的数据有文本和图片,怎么才能只显示文本内容不显示图片
- 还是一个数组重新排列的问题
- 服务器应用程序不可用.......... 为什么??
- 求教:往DataGrid控件添加新数据时,如何设置添加的数据是从行首开始插入?
- web.config如何设置才可以看到远程虚拟主机上的错误
- 在线等......20分,求怎样在DataGrid1中删除一行;
- 微软提供的示例都连不上数据库!!??
- 大家除夕快乐,散分,顺便问个技术问题,随便答答
- 关于实现接口ICloneable的效率问题。
- 我想用C#操作EXCEL,但引用ADO的时候无法引用。using System.Data.后面没有ADO命名空间
- 好久没来,不知不觉就到四个内裤了,现在有的换洗了哈哈~散分
{
e.Cancel = true;
this.WindowState = FormWindowState.Minimized
}
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Visible = false;
this.Icon(系统托盘图标).Visible = true;
}
}
private void notifyIcon1_Click(object sender, System.EventArgs e)
{
this.Visible = true;
this.WindowState = FormWindowState.Normal;
this.Icon.Visible = false;
}
你是要关闭还是最小化 想关闭的话在系统托盘图右健点退出吧。
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Visible = false;
this.notifyIcon1(系统托盘图标).Visible = true;
}
}
private void notifyIcon1_Click(object sender, System.EventArgs e)
{
this.Visible = true;
this.WindowState = FormWindowState.Normal;
this.notifyIcon1.Visible = false;
}
notifyIcon1 是个控件
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
protected override void WndProc(ref Message m)
{
const int SYSCMD = 0x0112;
const int CLOSE = 0xF060;
const int MINIMIZE = 0xF020; if (m.Msg == SYSCMD && ((int)m.WParam == MINIMIZE || (int)m.WParam == CLOSE))
{
//最小化到系统栏
base.WindowState = FormWindowState.Minimized;
base.Hide();
return;
}
base.WndProc(ref m);
} private void Open_Click(object sender, EventArgs e)
{
ShowForm();
} private void Exit_Click(object sender, EventArgs e)
{
Application.Exit();
} private void ShowForm()
{
if (!base.Visible)
{
base.Show();
}
if (base.WindowState == FormWindowState.Minimized)
{
Win32APIS.SendMessage(base.Handle, 0x112, 0xf120, 0);
}
base.Activate(); }
}Win32APIS.cs
public class Win32APIS
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam);
}
我刚刚写的demo,实际测试过的。