欢迎来到天天文库
浏览记录
ID:37708491
大小:117.50 KB
页数:13页
时间:2019-05-29
《C#如何在运行时通过鼠标拖动改变控件的大小》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、C#如何在运行时通过鼠标拖动改变控件的大小作者:oayx
2、出处:博客园
3、2011/10/2622:12:23
4、阅读13次usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Data;usingSystem.Windows.Forms;usingSystem.Drawing;namespaceWindowsApplication2{ classResizeAction { boolIsMoving=false; intctrlLastWidth
5、=0; intctrlLastHeight=0; intctrlWidth; intctrlHeight; intctrlLeft; intctrlTop; intcursorL; intcursorT; intctrlLastLeft; intctrlLastTop; intHtap; intWtap; boolctrlIsResizing=false; System.Drawing.Rectanglectrl
6、Rectangle=newSystem.Drawing.Rectangle(); privateControlctrl; privateFormfrm; publicResizeAction(Controlc,Formfrm) { ctrl=c; this.frm=frm; this.Htap=this.frm.Height-this.frm.ClientRectangle.Height; this.Wtap=this.frm.Width-
7、this.frm.ClientRectangle.Width; ctrl.MouseDown+=newMouseEventHandler(MouseDown); ctrl.MouseMove+=newMouseEventHandler(MouseMove); ctrl.MouseUp+=newMouseEventHandler(MouseUp); } publicvoidMouseMove(objectsender,MouseEventArgse) {
8、 if(frm==null) return; if(e.Button==MouseButtons.Left) { if(this.IsMoving) { if(ctrlLastLeft==0) ctrlLastLeft=ctrlLeft; if(ctrlLastTop==0) ctrlL
9、astTop=ctrlTop; intlocationX=(Cursor.Position.X-this.cursorL+this.frm.DesktopLocation.X+this.Wtap+this.ctrl.Location.X); intlocationY=(Cursor.Position.Y-this.cursorT+this.frm.DesktopLocation.Y+this.Htap+this.ctrl.Location.Y); if(loc
10、ationX
此文档下载收益归作者所有