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;
using System.Threading;
using System.IO;
namespace 弹出消息框
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public Form fmessage;
private void btnStart_Click(object sender, EventArgs e)
{
this.timer1.Enabled = true;
fmessage = new Form();
fmessage.Width = 350;
fmessage.Height = 280;
fmessage.MaximizeBox = false;
fmessage.MinimizeBox = false;
fmessage.Text = "武侠奇缘";
fmessage.BackgroundImage = Image.FromFile(@"F:\netstudy\work\画图和控件练习\弹出消息框\Resources\2.png");
Point p = new Point(Screen.PrimaryScreen.WorkingArea.Width - fmessage.Width, Screen.PrimaryScreen.WorkingArea.Height);
fmessage.PointToScreen(p);
fmessage.Location = p;
fmessage.Show();
for (int i = 0; i <= fmessage.Height; i++)
{
fmessage.Location = new Point(p.X, p.Y - i);
Thread.Sleep(10);
}
}
private void timer1_Tick_1(object sender, EventArgs e)
{
Thread.Sleep(2000);
int flag = 1;
while (flag==1)
{
while (true)
{
if ((System.Windows.Forms.Control.MousePosition.X >= fmessage.Location.X) && (System.Windows.Forms.Control.MousePosition.Y >= fmessage.Location.Y))
{
}
else
{
break;
}
}
timer1.Enabled = false;
Point p = new Point(Screen.PrimaryScreen.WorkingArea.Width - fmessage.Width, Screen.PrimaryScreen.WorkingArea.Height);
fmessage.PointToScreen(p);//
for (int i = fmessage.Height; i >= 0; i--)
{
//当鼠标又指上去的时候
if ((System.Windows.Forms.Control.MousePosition.X >= fmessage.Location.X) && (System.Windows.Forms.Control.MousePosition.Y >= fmessage.Location.Y))
{
fmessage.Location = new Point(p.X, p.Y);
flag = 1;
break;
}
flag = 0;
fmessage.Location = new Point(p.X, p.Y - i);
Thread.Sleep(10);
}
if (flag == 0)
{
break;
}
}
fmessage.Close();
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.IO;
namespace 弹出消息框
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public Form fmessage;
private void btnStart_Click(object sender, EventArgs e)
{
this.timer1.Enabled = true;
fmessage = new Form();
fmessage.Width = 350;
fmessage.Height = 280;
fmessage.MaximizeBox = false;
fmessage.MinimizeBox = false;
fmessage.Text = "武侠奇缘";
fmessage.BackgroundImage = Image.FromFile(@"F:\netstudy\work\画图和控件练习\弹出消息框\Resources\2.png");
Point p = new Point(Screen.PrimaryScreen.WorkingArea.Width - fmessage.Width, Screen.PrimaryScreen.WorkingArea.Height);
fmessage.PointToScreen(p);
fmessage.Location = p;
fmessage.Show();
for (int i = 0; i <= fmessage.Height; i++)
{
fmessage.Location = new Point(p.X, p.Y - i);
Thread.Sleep(10);
}
}
private void timer1_Tick_1(object sender, EventArgs e)
{
Thread.Sleep(2000);
int flag = 1;
while (flag==1)
{
while (true)
{
if ((System.Windows.Forms.Control.MousePosition.X >= fmessage.Location.X) && (System.Windows.Forms.Control.MousePosition.Y >= fmessage.Location.Y))
{
}
else
{
break;
}
}
timer1.Enabled = false;
Point p = new Point(Screen.PrimaryScreen.WorkingArea.Width - fmessage.Width, Screen.PrimaryScreen.WorkingArea.Height);
fmessage.PointToScreen(p);//
for (int i = fmessage.Height; i >= 0; i--)
{
//当鼠标又指上去的时候
if ((System.Windows.Forms.Control.MousePosition.X >= fmessage.Location.X) && (System.Windows.Forms.Control.MousePosition.Y >= fmessage.Location.Y))
{
fmessage.Location = new Point(p.X, p.Y);
flag = 1;
break;
}
flag = 0;
fmessage.Location = new Point(p.X, p.Y - i);
Thread.Sleep(10);
}
if (flag == 0)
{
break;
}
}
fmessage.Close();
}
}
}
实验结果截图: