我写了一个无标题的窗体已经可以拖动了,
但是怎样才能通过拖拽来改变无标题窗体的大小。
但是怎样才能通过拖拽来改变无标题窗体的大小。
解决方案 »
- Aspose.Words
- 为什么 GotFocus 事件,在设计器中没有,但是可以用代码加进去呢?
- BindingManagerBase.Position += 1为什么会有时候无效?
- 串口通信程序中,我自己的程序是单进程的,但是为何会造成程序中多个进程来同时访问日志文件呢
- C#软件打包生成问题!!!
- 求一sql高手来帮帮小弟啊
- C#网络应用编程的问题,请在百忙中看一看
- 网页中插入在线QQ,必须要加为好友时可以实现临时对话
- C#小白,VS2010创建C#控制台应用程序提示"调用的目标发生异常" 怎么办,之前在在vs2010写过C++程序没问题
- 关于LOCK的问题!
- byte数组中的汉字处理问题?急等
- C# Winform 的两个问题
bord用于记录是那个边被选中.
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (beginsiae)
{
if((bord&1)!=0)
if ((this.Height + currentY - MousePosition.Y) > 20)
{
this.Height = this.Height + currentY - MousePosition.Y;
this.Top = this.Top + MousePosition.Y - currentY;
}
if((bord&2)!=0)
if ((this.Width + MousePosition.X - currentX) > 20)
this.Width = this.Width + MousePosition.X - currentX;
if((bord&4)!=0)
if ((this.Height + MousePosition.Y - currentY) > 20)
this.Height = this.Height + MousePosition.Y - currentY;
if((bord&8)!=0)
if ((this.Width + currentX - MousePosition.X) > 20)
{
this.Width = this.Width + currentX - MousePosition.X;
this.Left=this.Left+MousePosition.X-currentX; }
currentX=MousePosition.X;
currentY=MousePosition.Y; }
else
{
if (Math.Abs(this.Location.X - MousePosition.X) < 10)
bord = bord | 8;
else
bord = bord & 7; if (Math.Abs(this.Location.X + this.Width - MousePosition.X) < 10)
bord = bord | 2;
else
bord = bord & 13; if (Math.Abs(this.Location.Y - MousePosition.Y) < 10)
bord = bord | 1;
else
bord = bord & 14; if (Math.Abs(this.Location.Y + this.Height - MousePosition.Y) < 10)
bord = bord | 4;
else
bord = bord & 11;
switch (bord)
{
case 1:
case 4:
this.Cursor = Cursors.SizeNS;
break;
case 2:
case 8:
this.Cursor = Cursors.SizeWE;
break;
case 3:
case 12:
this.Cursor = Cursors.SizeNESW;
break;
case 9:
case 6:
this.Cursor = Cursors.SizeNWSE;
break;
default:
this.Cursor = Cursors.Default;
break;
}
} } int currentX = 0;
int currentY = 0;
bool beginsiae = false;
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (bord==0)
return;
else
{
currentX = MousePosition.X;
currentY = MousePosition.Y;
beginsiae = true;
} } private void Form1_MouseUp(object sender, MouseEventArgs e)
{
beginsiae = false;
bord = 0;
currentX = 0;
currentY = 0;
}