开发环境:VS2005
开发语言:C#我在自己定义的窗体上添加 [能通过鼠标拖动改变窗体大小功能]时遇到了一下问题。1 鼠标和窗体改变不同步2 鼠标在快速滑动经过边框时,鼠标的样式 从defalut--->变成sizeNe-->但是经过能拖动的
区域后不能变回defalut。请高手指点:代码如下:
private void BaseForm_MouseDown(object sender, MouseEventArgs e)
{
this.MouseStartPositionX = e.X;
this.MouseStartPositionY = e.Y;
this.ButtonPress = true;
if (e.X > this.Width - 2 && e.Y < this.Height - 2)
{
this.MoveStatus = 1;
}
else if (e.X > this.Width - 2 && e.Y > this.Height - 2)
{
this.moveStatus = 2;
}
else if (e.Y > this.Height - 2 && e.X < this.Width - 2)
{
this.moveStatus = 3;
}
else
{
this.Cursor = Cursors.Default;
this.moveStatus = 0;
this.ButtonPress = false;
}
this.FormWith = this.Width;
this.Formheight = this.Height;
}
int mi = 1;
private void BaseForm_MouseMove(object sender, MouseEventArgs e)
{
this.MouseEndPositionX = e.X;
this.MouseEndPositionY = e.Y;
//if (e.X < this.Width - 5 && e.Y < this.Height - 5)
//{
// this.Cursor = Cursors.Default;
//} if (e.X > this.Width - 2 && e.Y < this.Height - 2)
{
this.Cursor = Cursors.SizeWE;
}
else if (e.X > this.Width - 2 && e.Y > this.Height - 2)
{
this.Cursor = Cursors.SizeNWSE; }
else if (e.Y > this.Height - 2 && e.X < this.Width - 2)
{
this.Cursor = Cursors.SizeNS; }
else
{
this.Cursor = Cursors.Default;
} if (this.ButtonPress)
{
if (mi > 20)
{
int m = this.FormWith + this.mouseEndPositionX - this.mouseStartPositionX;
int n = this.Formheight + this.mouseEndPositionY - this.mouseStartPositionY;
this.Size = new Size(m, n);
mi = 1;
} }
mi = mi + 1;
} private void BaseForm_MouseUp(object sender, MouseEventArgs e)
{
this.Cursor = Cursors.Default;
this.ButtonPress = false;
this.MoveStatus = 0;
}
开发语言:C#我在自己定义的窗体上添加 [能通过鼠标拖动改变窗体大小功能]时遇到了一下问题。1 鼠标和窗体改变不同步2 鼠标在快速滑动经过边框时,鼠标的样式 从defalut--->变成sizeNe-->但是经过能拖动的
区域后不能变回defalut。请高手指点:代码如下:
private void BaseForm_MouseDown(object sender, MouseEventArgs e)
{
this.MouseStartPositionX = e.X;
this.MouseStartPositionY = e.Y;
this.ButtonPress = true;
if (e.X > this.Width - 2 && e.Y < this.Height - 2)
{
this.MoveStatus = 1;
}
else if (e.X > this.Width - 2 && e.Y > this.Height - 2)
{
this.moveStatus = 2;
}
else if (e.Y > this.Height - 2 && e.X < this.Width - 2)
{
this.moveStatus = 3;
}
else
{
this.Cursor = Cursors.Default;
this.moveStatus = 0;
this.ButtonPress = false;
}
this.FormWith = this.Width;
this.Formheight = this.Height;
}
int mi = 1;
private void BaseForm_MouseMove(object sender, MouseEventArgs e)
{
this.MouseEndPositionX = e.X;
this.MouseEndPositionY = e.Y;
//if (e.X < this.Width - 5 && e.Y < this.Height - 5)
//{
// this.Cursor = Cursors.Default;
//} if (e.X > this.Width - 2 && e.Y < this.Height - 2)
{
this.Cursor = Cursors.SizeWE;
}
else if (e.X > this.Width - 2 && e.Y > this.Height - 2)
{
this.Cursor = Cursors.SizeNWSE; }
else if (e.Y > this.Height - 2 && e.X < this.Width - 2)
{
this.Cursor = Cursors.SizeNS; }
else
{
this.Cursor = Cursors.Default;
} if (this.ButtonPress)
{
if (mi > 20)
{
int m = this.FormWith + this.mouseEndPositionX - this.mouseStartPositionX;
int n = this.Formheight + this.mouseEndPositionY - this.mouseStartPositionY;
this.Size = new Size(m, n);
mi = 1;
} }
mi = mi + 1;
} private void BaseForm_MouseUp(object sender, MouseEventArgs e)
{
this.Cursor = Cursors.Default;
this.ButtonPress = false;
this.MoveStatus = 0;
}
解决方案 »
- winform窗体关闭后再次打开问题。
- C# winform datagridview 怎样删除空行
- windows下如何监控监控进程状态?
- Dev 中的treelist和gridControl的用法 能给出一个小程序么?
- windows7下 Asp.net调用支付接口的时候,证书验证错误
- 再水一贴......
- 遇到一个打印数组的例子,有些不明白。
- word的Table对象可以给excel的table对象赋值吗?
- 想把Socket通讯程序服务端做成服务,能够连接多个客户端,怎么写呀?
- 用c#开发的webservice怎么样才能在Linux里使用
- 如何更改引用dll(.Net私有程序集)的路径
- xml转treeview问题求教
请在MSDN中查阅WM_NCHITTEST消息的处理,可以很好的实现LZ所期望的效果。