class for Dragging Form in .NET
2006-04-12 10:07
246 查看
internal class FormDrag
{
Form _form=null ;
int _y = 0, _x = 0;
private bool _mousedown = false;
public FormDrag(Form form)
{
if (form == null)
throw new ArgumentNullException("Must pass a form instance.");
_form = form;
_form.MouseMove += new MouseEventHandler(_form_MouseMove);
_form.MouseDown += new MouseEventHandler(_form_MouseDown);
_form.MouseUp += new MouseEventHandler(_form_MouseUp);
}
void _form_MouseUp(object sender, MouseEventArgs e)
{
_mousedown = false;
}
void _form_MouseDown(object sender, MouseEventArgs e)
{
_mousedown = true;
_y = e.Y;
_x = e.X;
}
void _form_MouseMove(object sender, MouseEventArgs e)
{
if (_mousedown)
{
int a = _y - e.Y;
_form.Top -= a;
a = _x - e.X;
_form.Left -= a;
}
}
}
{
Form _form=null ;
int _y = 0, _x = 0;
private bool _mousedown = false;
public FormDrag(Form form)
{
if (form == null)
throw new ArgumentNullException("Must pass a form instance.");
_form = form;
_form.MouseMove += new MouseEventHandler(_form_MouseMove);
_form.MouseDown += new MouseEventHandler(_form_MouseDown);
_form.MouseUp += new MouseEventHandler(_form_MouseUp);
}
void _form_MouseUp(object sender, MouseEventArgs e)
{
_mousedown = false;
}
void _form_MouseDown(object sender, MouseEventArgs e)
{
_mousedown = true;
_y = e.Y;
_x = e.X;
}
void _form_MouseMove(object sender, MouseEventArgs e)
{
if (_mousedown)
{
int a = _y - e.Y;
_form.Top -= a;
a = _x - e.X;
_form.Left -= a;
}
}
}
相关文章推荐
- .net邮件错误 :The specified string is not in the form required for a subject.
- Mybaits注解方式 There is no getter for property named 'name' in 'class java.lang.String'
- Plug-in "net.sourceforge.jode" was unable to instantiate class "net.sourcefo
- Why .Net databinding does not support for class field?
- You can't specify target table 'wms_cabinet_form' for update in FROM clause
- mybatis报错 There is no getter for property named 'xx' in 'class java.lang.String
- There is no getter for property named 'name' in 'class java.lang.Integer'
- ASP.NET MVC 3 Beta: Built-in support for charts(MVC3 Razor中使用图表的最佳方案)
- No configuration found for the specified action: '/login.action' in namespace: '/myNameSpace'. Form
- Developing Application Frameworks in .Net--(Note2, Configuration/Class Factory)
- ASP.NET操作EXCEL时出现的错误 Retrieving the COM class factory for component with CLSID
- Writing a Custom Membership Provider for the Login Control in ASP.NET 2.0
- 统计在线用户列表 for .net WebForm
- (SPP-net)Spatial Pyramid Pooling in deep convolutional networks for visual recognition
- Allow Only Ajax Requests For An Action In ASP.NET Core
- There is no getter for property named 'xxx' in 'class java.lang.String
- A duplicate insert block exists for class "COneValuDlg" in the source files
- RCNN学习笔记(3):Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition(SPP-net)
- Comparing the Timer Classes in the .NET Framework Class Library
- 【Mybatis】There is no getter for property named 'type' in 'class java.lang.String'