求vs2005 winform 仿QQ窗体特效 求仿QQ窗体,将窗体拖到桌面顶上或边上,窗体就自动隐藏的特效代码。还有窗体最小化到任务栏右下角图标,双击图标又弹出窗体的特效代码。谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 第一个功能,鼠标按住界面可以拉动,并获得屏幕分辨率和界面坐标,然后进行隐藏。 这个只是加减代码。第二个功能,notifyIcon控件+右键控件(右下角图标右键效果)。//最小化 → 正常 private void MinimizedToNormal() { this.Visible = true; this.WindowState = FormWindowState.Normal; 显示ToolStripMenuItem.Text = "隐藏窗口"; } //正常 → 最小化 private void NormalToMinimized() { this.WindowState = FormWindowState.Minimized; this.Visible = false; 显示ToolStripMenuItem.Text = "显示窗口"; } //界面点击X关闭后 取消关闭 最小化 private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { this.NormalToMinimized(); e.Cancel = true; }//双击右下角图标时 会调用的notifyIcon控件的鼠标双击事件 private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (this.WindowState == FormWindowState.Minimized)//当窗口是最小化时。 { this.MinimizedToNormal(); } else if (this.WindowState == FormWindowState.Normal)//当窗口是最大化时。 { this.NormalToMinimized(); } } }自己找找notifyIcon控件的使用方法。 第一个功能我自己是这样的,不知道有没有更好的办法。同求。//窗体 鼠标拉动 [DllImport("user32.dll")] public static extern bool ReleaseCapture(); [DllImport("user32.dll")] public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam); public const int WM_SYSCOMMAND = 0x0112; public const int SC_MOVE = 0xF010; public const int HTCAPTION = 0x0002; //界面MouseDown事件 private void Form1_MouseDown(object sender, MouseEventArgs e) { ReleaseCapture(); SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0); } //界面MouseMove事件 private void Form1_MouseMove(object sender, MouseEventArgs e) { if (this.Location.X < 0) { this.Location = new Point(0, this.Location.Y); } if (this.Location.X > System.Windows.Forms.SystemInformation.WorkingArea.Width - this.Size.Width) { this.Location = new Point(System.Windows.Forms.SystemInformation.WorkingArea.Width - this.Size.Width, this.Location.Y); } if (this.Location.Y > System.Windows.Forms.SystemInformation.WorkingArea.Height - this.Size.Height) { this.Location = new Point(this.Location.X, System.Windows.Forms.SystemInformation.WorkingArea.Height - this.Size.Height); } } c#线性表的语法,有点看不明,高手进来指法下! 自定义实体类与结构类型 C#程序解释 this.Controls.Add(listBox1);中的this是什么意思 查询付值问题,自动生成一个窗体 关于银联终端报文接口 关于XML更改结点名的问题 Anakrino反编译器,怎么用啊。我使用时总是报内存不能为READ的错误,根本大不开DLL如何解决. 直接为颜色赋值怎么写? 关于即时提醒的问题 报表新手问题,求助 报表的问题
这个只是加减代码。
第二个功能,notifyIcon控件+右键控件(右下角图标右键效果)。
//最小化 → 正常
private void MinimizedToNormal()
{
this.Visible = true;
this.WindowState = FormWindowState.Normal;
显示ToolStripMenuItem.Text = "隐藏窗口";
}
//正常 → 最小化
private void NormalToMinimized()
{
this.WindowState = FormWindowState.Minimized;
this.Visible = false;
显示ToolStripMenuItem.Text = "显示窗口";
} //界面点击X关闭后 取消关闭 最小化
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
this.NormalToMinimized();
e.Cancel = true;
}
//双击右下角图标时 会调用的notifyIcon控件的鼠标双击事件
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (this.WindowState == FormWindowState.Minimized)//当窗口是最小化时。
{
this.MinimizedToNormal();
}
else if (this.WindowState == FormWindowState.Normal)//当窗口是最大化时。
{
this.NormalToMinimized();
} }
}
自己找找notifyIcon控件的使用方法。
//窗体 鼠标拉动
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x0002; //界面MouseDown事件
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
} //界面MouseMove事件
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (this.Location.X < 0)
{
this.Location = new Point(0, this.Location.Y);
}
if (this.Location.X > System.Windows.Forms.SystemInformation.WorkingArea.Width - this.Size.Width)
{
this.Location = new Point(System.Windows.Forms.SystemInformation.WorkingArea.Width - this.Size.Width, this.Location.Y);
}
if (this.Location.Y > System.Windows.Forms.SystemInformation.WorkingArea.Height - this.Size.Height)
{
this.Location = new Point(this.Location.X, System.Windows.Forms.SystemInformation.WorkingArea.Height - this.Size.Height);
}
}