预览加载中,请您耐心等待几秒...
1/5
2/5
3/5
4/5
5/5

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

usingSystem; usingSystem.Collections.Generic; usingSystem.ComponentModel; usingSystem.Data; usingSystem.Drawing; usingSystem.Text; usingSystem.Windows.Forms; namespaceWindowsApplication11 { publicpartialclassForm1:Form { privateintoldx; privateintoldy; enummPosition { left, right, top, bottom } privatemPositionadjust; publicForm1() { InitializeComponent(); } privatevoidbutton1_MouseDown(objectsender,MouseEventArgse) { oldx=e.X; oldy=e.Y; } privatevoidbutton1_MouseMove(objectsender,MouseEventArgse) { RectanglerectLeft=newRectangle(0,2,2,button1.Height-4); RectanglerectRight=newRectangle(button1.Width-2,2,2,button1.Width); RectanglerectTop=newRectangle(2,0,button1.Width-4,2); RectanglerectBottom=newRectangle(2,button1.Height-2,button1.Width-4,2); if(rectLeft.Contains(e.X,e.Y)) { adjust=mPosition.left; button1.Cursor=Cursors.SizeWE; } elseif(rectRight.Contains(e.X,e.Y)) { adjust=mPosition.right; button1.Cursor=Cursors.SizeWE; } elseif(rectTop.Contains(e.X,e.Y)) { adjust=mPosition.top; button1.Cursor=Cursors.SizeNS; } elseif(rectBottom.Contains(e.X,e.Y)) { adjust=mPosition.bottom; button1.Cursor=Cursors.SizeNS; } else { button1.Cursor=Cursors.Default; } } privatevoidbutton1_MouseUp(objectsender,MouseEventArgse) { if(e.Button==System.Windows.Forms.MouseButtons.Left) { intdx=e.X-oldx; intdy=e.Y-oldy; switch(adjust) { casemPosition.left: button1.Left+=dx; button1.Width-=dy; break; casemPosition.right: button1.Width+=dx; break; casemPosition.top: button1.Top+=dy; button1.Height-=dy; break; casemPosition.bottom: button1.Height+=dy; break; } } } } } 另外一种比较好的 privatevoidbutton1_MouseMove(objectsender,MouseEventArgse) { intright=((Button)sender).Width; intbottom=((Button)sender).Height; if(e.X>(right-10)&&e.Y>(bottom-10)) { ((Button)sender).Cursor=Cursors.SizeNWSE; } elseif(e.X>(right-10)) { ((Button)sender).Cursor=Cursors.VSplit; } elseif(e.Y>(bottom-10)) { ((Button)sender).Cursor=Cursors.HSplit; } else { ((Button)sender).Cursor=Cursors.Default; } if(e.Button==