private void DrawMiddle_Left(Graphics g)
{
Brush brush = new TextureBrush(Middle_Left, new Rectangle(0, 0,
Middle_Left.Width, Middle_Left.Height));
g.FillRectangle(brush, 0, TITLE_WIDTH, Middle_Left.Width,
Height - Bottom_Middle.Height - TITLE_WIDTH);
}
public class MouseSizeRight : MouseAction
{
private int lx;
public MouseSizeRight(int LocationX)
{
lx = LocationX;
}
public override void Action(int ScreenX, int ScreenY, System.Windows.Forms.Form form)
{
form.Width = ScreenX - lx;
form.Invalidate();
}
}
public class MouseDrag : MouseAction
{
private int x, y;
public MouseDrag(int hitX, int hitY)
{
x = hitX;
y = hitY;
}
public override void Action(int ScreenX, int ScreenY, System.Windows.Forms.Form form)
{
form.Location = new Point(ScreenX - x, ScreenY - y);
}
}
//鼠标点击左上边框
if((e.X <= LEFT + 10 && e.Y <= TOP) || (e.Y <= TOP + 10 && e.X <= LEFT))
{
mouse = new MouseSizeTopLeft(Location.X, Location.Y, Width, Height);
return;
}
//鼠标点击系统关闭按纽
if(e.X > Width - 20 && e.Y > 6 && e.X < Width - 20 + SysButton_Min.Width && e.Y < 6 + SysButton_Min.Height)
{
Close();
return;
}
private void Form_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.Parent.Cursor = CheckCursorType(e.X, e.Y);//改变鼠标的指针形状
if(mouse != null)
{
mouse.Action(Control.MousePosition.X, Control.MousePosition.Y, this);//执行时间响应
//注意坐标是Control.MousePosition这个静态变量给出的,它的值为鼠标在桌面上的全局坐标
}
}
private Cursor CheckCursorType(int X, int Y)
{
if(((X <= LEFT + 10 && Y <= TOP) || (Y <= TOP + 10 && X <= LEFT))
|| ((X >= Width - RIGHT - 10 && Y >= Height - BOTTOM)
|| (Y >= Height - BOTTOM - 10 && X >= Width - RIGHT)))
{
return Cursors.SizeNWSE;
}
else if(((Y <= TOP + 10 && X >= Width - RIGHT)
|| (Y <= TOP && X >= Width - RIGHT - 10))
|| ((X <= LEFT && Y >= Height - BOTTOM - 10)
|| (Y >= Height - BOTTOM && X <= LEFT + 10)))
{
return Cursors.SizeNESW;
}
else if(X >= Width - RIGHT || X <= LEFT)
{
return Cursors.SizeWE;
}
else if(Y >= Height - BOTTOM || Y <= TOP)
{
return Cursors.SizeNS;
}
else
{
return Cursors.Arrow;
}
}
private void Form_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
mouse = null;
}
private void Form_DoubleClick(object sender, System.EventArgs e)
{
if(y > TOP && y < TITLE_WIDTH)
{
if(WindowState == FormWindowState.Normal)
{
WindowState = FormWindowState.Maximized;
SysButton = SysButton_Restore;
Invalidate();
}
else if(WindowState == FormWindowState.Maximized)
{
WindowState = FormWindowState.Normal;
SysButton = SysButton_Max;
Invalidate();
}
}
}
相关视频
相关阅读 Visual C#事件与接口编程实例用Visual C#动态生成组件用Visual C#来清空回收站2用Visual C#来清空回收站1用Visual C#来增加数据记录2用Visual C#来增加数据记录1用Visual C#中轻松浏览数据库记录用Visual C#获得计算机名称和IP地址
热门文章 没有查询到任何记录。
最新文章
什么是.NET中的TDD?ASP.NET AJAX入门简介
WebMatrix入门教程VC++2008中如何调用GetOpenFileName打开文件PlaySound函数在VC++6.0中如何播放音乐及声请问VC++回调函数怎么用
人气排行 嵌入式实时操作系统VxWorks入门教程ArrayList 与 string、string[] 的转换C#遍历整个文件夹及子目录的文件代码WebMatrix入门教程asp.net判断文件或文件夹是否存在c#判断数据NULL值的方法vc++6.0怎么写Windows简单窗口代码.net解决数据导出excel时的格式问题
查看所有0条评论>>