手柄控件
来源:互联网 发布:js倒计时5秒跳转 编辑:程序博客网 时间:2024/06/10 01:13
在StatusBar上有一个可以拖动窗体大小的手柄,鼠标在其上拖动时就可以调整当前窗体的大小,如何自己来仿制一个呢,我作了一个小控件就可以实现了,只是效果上相似,至于系统里到底是怎么来实现的,我是不知道的了,下面是控件的代码,没有写注释,因为怕有人笑我,呵呵,其实简单的不用写注释了:
using System;
using System.Drawing;
using System.Windows.Forms;
namespace Size_MoveCtr
{
/// <summary>
/// Mover 的摘要说明。
/// </summary>
public class SizeGrip: System.Windows.Forms.Control
{
private const int WM_NCHITTEST = 0x84;
private const int WM_NCLBUTTONDOWN = 0xa1;
private const int HTCLIENT = 1;
private const int HTBOTTOMRIGHT = 17;
private System.Drawing.Drawing2D.GraphicsPath m_Path;
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern int SendMessage( IntPtr hWnd,
int Msg,
IntPtr wParam,
IntPtr lParam
);
public SizeGrip()
{
this.m_Path = new System.Drawing.Drawing2D.GraphicsPath();
this.m_Path.StartFigure();
this.m_Path.AddLines(new Point[]{new Point(this.Width, 0),new Point(this.Width-this.Height, this.Height), new Point(this.Width, this.Height)});
this.m_Path.CloseFigure();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint (e);
ControlPaint.DrawSizeGrip(this.CreateGraphics(), System.Drawing.SystemColors.Control, this.Width-this.Height, 0, this.Height, this.Height);
}
protected override void OnSizeChanged(EventArgs e)
{
System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
path.StartFigure();
path.AddLines(new Point[]{new Point(this.Width, 0),new Point(this.Width-this.Height, this.Height), new Point(this.Width, this.Height)});
path.CloseFigure();
Region reReg = new Region(path);
reReg.Complement(m_Path);
this.Invalidate(reReg);
base.OnSizeChanged(e);
this.m_Path = path;
ControlPaint.DrawSizeGrip(this.CreateGraphics(), System.Drawing.SystemColors.Control, this.Width-this.Height, 0, this.Height, this.Height);
}
protected override void WndProc(ref Message m)
{
if (this.DesignMode)
{
base.WndProc(ref m);
return;
}
switch (m.Msg)
{
case WM_NCHITTEST:
SendMessage(this.Parent.Handle, m.Msg, m.WParam, m.LParam);
base.WndProc(ref m);
if ((int)m.Result == HTCLIENT)
{
m.Result = (IntPtr)HTBOTTOMRIGHT;//右下
}
break;
case WM_NCLBUTTONDOWN:
SendMessage(this.Parent.Handle, m.Msg, m.WParam, m.LParam);
break;
default:
base.WndProc(ref m);
break;
}
}
}
}
- 手柄控件
- 自定义控件之 Gamepad (游戏手柄)
- cocos2dx 手柄
- daydream手柄
- 无线手柄
- USB手柄的控制
- xbox360手柄连主机
- 南极 V43 手柄
- 模拟游戏手柄软键盘
- 手机无线手柄 使用说明
- android游戏手柄问题
- ps3手柄与ros
- 10手柄服务
- 游戏手柄 GameController
- ios手柄研究
- 手柄输入子系统事件
- 游戏手柄设置
- Unity 手柄/键盘映射
- 【源译】使用自定义的VuGen脚本模板
- 老婆在婚前和婚后的差别
- 关于转正报告
- 【源译】web_url函数的一个细节问题
- 实战JBOSS――教你写第一个EJB
- 手柄控件
- 毫秒级别精确延时
- Visual FoxPro9.0中扩展报表系统功能
- LENOVEL
- 【原创】从Controller中监视VU执行脚本的情况
- 在IE6.0SP1中去掉IE标题栏同时控制IE大小
- Linux下面Gateway,DNS,Http,FTP的实现(三)
- 计算机学习的小方法论
- 用最快的速度读技术书