By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,645 Members | 1,078 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,645 IT Pros & Developers. It's quick & easy.

Move the windowform

P: n/a
Hi All Pro,

First, thanks you all in advance for your kindest help, I am very
appreciated. I did have two event on the form, which are:
Form1_MouseDown(...) and Form1_MouseMove. The problem is: my form didn't
move at all when I do move the mouse. But, If I have a breakpoint at
mousedown, when I hit F5 to run the application, the form did move. What am
I doing wrong?

Kate,

Below is the code:

private void Form1_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e)

{

_MouseOffset = new Point( -e.X, -e.Y );

}

private void Form1_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)

{

if( e.Button.Equals( MouseButtons.Left ) )

{

Point MousePos = Control.MousePosition;

MousePos.Offset( this._MouseOffset.X, this._MouseOffset.Y );

Location = MousePos;

}

}
Feb 27 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
If you're just looking to be able to move a form using the client area then
the following link may be useful.
http://support.microsoft.com/?id=320687

--
Tim Wilson
..NET Compact Framework MVP

"cql90" <cq***@yahoo.com> wrote in message
news:uB**************@TK2MSFTNGP12.phx.gbl...
Hi All Pro,

First, thanks you all in advance for your kindest help, I am very
appreciated. I did have two event on the form, which are:
Form1_MouseDown(...) and Form1_MouseMove. The problem is: my form didn't
move at all when I do move the mouse. But, If I have a breakpoint at
mousedown, when I hit F5 to run the application, the form did move. What am I doing wrong?

Kate,

Below is the code:

private void Form1_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e)

{

_MouseOffset = new Point( -e.X, -e.Y );

}

private void Form1_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)

{

if( e.Button.Equals( MouseButtons.Left ) )

{

Point MousePos = Control.MousePosition;

MousePos.Offset( this._MouseOffset.X, this._MouseOffset.Y );

Location = MousePos;

}

}

Feb 27 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.