Winform如何做像QQ天气一样,若天气窗体获得鼠标则不关闭,否则过会就关闭 Winform如何做像QQ天气一样,若天气窗体获得鼠标则不关闭,否则过会就关闭。并且像天气窗体一样无法移动。停靠在主窗体边上。QQ天气停靠 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 主窗体代码using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Windows.Forms;namespace WindowsFormsApplication2{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } public Form2 m_frm2=null; //天气窗体 private void Form1_Load(object sender, EventArgs e) { this.MouseMove += Form1_MouseMove; } void Form1_MouseMove(object sender, MouseEventArgs e) { this.Text = e.X + "," + e.Y; if (m_frm2 != null) return; if (e.X > 100 && e.Y > 100 && e.X < 200 && e.Y < 200) //主窗体(Form1)鼠标进入[100,100]-[200,200]区域显示天气窗体(Form2) { m_frm2 = new Form2(); m_frm2.m_frm1 = this; m_frm2.Show(); } } }}天气窗体代码using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace WindowsFormsApplication2{ public partial class Form2 : Form { public Form2() { InitializeComponent(); } public Form1 m_frm1 = null; //主窗体 private void Form2_Load(object sender, EventArgs e) { if (m_frm1 != null) { this.Left = m_frm1.Left - this.Width; this.Top = m_frm1.Top; } this.FormBorderStyle = FormBorderStyle.None; this.MouseLeave += Form2_MouseLeave; } void Form2_MouseLeave(object sender, EventArgs e) //鼠标移出,关闭天气窗体 { if (m_frm1 != null) m_frm1.m_frm2 = null; this.Close(); } }} c#文件调用问题 c#连接数据库问题 C# ListBox 设置为透明化 DLL签名问题,急!! WebDev.WebServer.EXE: 托管”已退出,返回值为 0 (0x0)。 菜鸟提问 大家别笑! C# MySQL本地存图片错误 请大家告诉我如何把做好的程序移植到其他机器上,并使之正常运行 使用C#+rar.exe压缩文件,对于有空格名的文件无法压缩,求解。 C# 中如何取二维数组的指定一维作为参数传递 有么有人会用Aspose.Words?有一个问题求解!!! 执行存储过程,如何添加进度条
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public Form2 m_frm2=null; //天气窗体 private void Form1_Load(object sender, EventArgs e)
{
this.MouseMove += Form1_MouseMove;
} void Form1_MouseMove(object sender, MouseEventArgs e)
{
this.Text = e.X + "," + e.Y; if (m_frm2 != null)
return; if (e.X > 100 && e.Y > 100 && e.X < 200 && e.Y < 200) //主窗体(Form1)鼠标进入[100,100]-[200,200]区域显示天气窗体(Form2)
{
m_frm2 = new Form2();
m_frm2.m_frm1 = this;
m_frm2.Show(); }
} }
}天气窗体代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;namespace WindowsFormsApplication2
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
} public Form1 m_frm1 = null; //主窗体 private void Form2_Load(object sender, EventArgs e)
{
if (m_frm1 != null)
{
this.Left = m_frm1.Left - this.Width;
this.Top = m_frm1.Top;
}
this.FormBorderStyle = FormBorderStyle.None;
this.MouseLeave += Form2_MouseLeave;
} void Form2_MouseLeave(object sender, EventArgs e) //鼠标移出,关闭天气窗体
{
if (m_frm1 != null)
m_frm1.m_frm2 = null; this.Close();
} }
}