using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.Opacity = 0; Timer tStart = new Timer(); tStart.Interval = 10; tStart.Tick += new EventHandler(tStart_Tick); tStart.Start(); } void tStart_Tick(object sender, EventArgs e) { this.Opacity += 0.01; if (this.Opacity == 1) ((Timer)sender).Stop(); } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (this.Opacity > 0) e.Cancel = true; Timer tClose = new Timer(); tClose.Interval = 10; tClose.Tick += new EventHandler(tClose_Tick); tClose.Start(); } void tClose_Tick(object sender, EventArgs e) { this.Opacity -= 0.01; if (this.Opacity <= 0) { ((Timer)sender).Stop(); this.Close(); } } private Point mouse_offset; private void Common_MouseUp(object sender, MouseEventArgs e) { //if (e.Button == MouseButtons.Left) //{ // Point mousePos = Control.MousePosition; // mousePos.Offset(mouse_offset.X, mouse_offset.Y); // ((Control)sender).Location = ((Control)sender).Parent.PointToClient(mousePos); //} } private void Common_MouseDown(object sender, MouseEventArgs e) { mouse_offset = new Point(-e.X, -e.Y); } private void Common_MouseMove(object sender, MouseEventArgs e) { ((Control)sender).Cursor = Cursors.Arrow; if (e.Button == MouseButtons.Left) { Point mousePos = Control.MousePosition; mousePos.Offset(mouse_offset.X, mouse_offset.Y); ((Control)sender).Location = ((Control)sender).Parent.PointToClient(mousePos); //mousepostion.Text = mousePos.ToString(); } //controlpostion.Text = Control.MousePosition.ToString(); //mouseoffset.Text = mouse_offset.ToString(); } } }