Introduction
It is a bit tricky in Visual Studio to create a movable free form window (irrespective of the language you choose). Here I am going to show you how easy it is.Step 1
Create a form in C# and add one exit button too.
Step 2
Change the properties of the form like this. Change the Form Border Style as none and Transparence key to 'control'.
Step 3
Add a picture box and a picture to the form.
Step 4
Now the final and the tricky part comes into the picture. Create the following mouse events for the newly created form.
C#
public int diff_x; public int diff_y; public bool mouse_down = false; private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { diff_x = Form.MousePosition.X - Form.ActiveForm.Location.X; diff_y = Form.MousePosition.Y - Form.ActiveForm.Location.Y; mouse_down = true; }public variable mouse_down to true.TypeScript
private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (mouse_down == true) { Point p = new Point(MousePosition.X - diff_x, MousePosition.Y - diff_y); Form.ActiveForm.Location = p; } }TypeScript
private void pictureBox1_MouseUp(object sender, MouseEventArgs e) { mouse_down = false; }mouse_down to false. Add the following code to your exit button. Otherwise, you will face difficulty in closing your application.
TypeScript
private void button1_Click(object sender, EventArgs e) { Dispose(); this.Close(); }Finally here is our movable transparent window in action!

Nikhil KumarPosted Sep 22, 2009, 6:53 PM EDT
nICE aRTICLE jIMMY........ :)