C#中的TreeView放在一个MDI Form中后能不能让它能够利用鼠标拖动改变他的大小? 你可以通过DOCK=FILL的方式来调整,把它放到PANDEL中这样可以保证其它控件的位置,否则,界面就乱了群:6831395 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以的.但你最好从TreeView自己来继承一个类,然后在里面添加类似如下的代码就行了:private const int WM_NCHITTEST = 0x84;private const int HTCLIENT = 0x1;private const int HTSIZE = 0x4;private const int HTCAPTION = 0x2; private const int WM_SIZING = 532;private const int HTMINBUTTON = 8;private const int BorderWidth = 5;//可以调整窗体的大小和移动窗体的位置protected override void WndProc(ref Message m){ switch(m.Msg) { case WM_NCHITTEST: base.WndProc(ref m); if (DesignMode) { return; } if ((int)m.Result == HTCLIENT) if ((Cursor.Position.X<=this.Left + BorderWidth) && (Cursor.Position.Y <= this.Top + BorderWidth)) m.Result = (IntPtr)13;//左上 else if ((Cursor.Position.X>=this.Left + this.Width-BorderWidth) && (Cursor.Position.Y<=this.Top +BorderWidth)) m.Result = (IntPtr)14;//右上 else if ((Cursor.Position.X <= this.Left + BorderWidth) && (Cursor.Position.Y>=this.Top + this.Height-BorderWidth)) m.Result = (IntPtr)16;//左下 else if ((Cursor.Position.X>=this.Left + this.Width-BorderWidth) && (Cursor.Position.Y>=this.Top + this.Height-BorderWidth)) m.Result = (IntPtr)17;//右下 else if (Cursor.Position.X<=this.Left + BorderWidth) m.Result = (IntPtr)10;//左 else if (Cursor.Position.X>=this.Left + this.Width-BorderWidth) m.Result = (IntPtr)11;//右 else if (Cursor.Position.Y<=this.Top + BorderWidth) m.Result = (IntPtr)12;//上 else if (Cursor.Position.Y>=this.Top + this.Height-BorderWidth) m.Result = (IntPtr)15;//下 else m.Result = (IntPtr)HTCAPTION;//移动窗体 return; default: base.WndProc(ref m); break; }} } can't create component 'AxHost' 如何知道父窗体的名称是谁 菜鸟求救:注册新用户时,为什么不能上传图片并显示出来。。 如何实现:WPF中播放视频时从任意位置开始,任意长度的回放 报表绘制问题,利用位图字节流在报表中显示一张图片 关于Menu的问题 datagirdview控件的问题 弱弱的小白求助 关于字符串string大小写转换问题 请问QQ输入号码那个功能怎么实现的,求思路 C# 读取excel中的数据并赋值给数组 关于钩子问题 如果我有一个form, 又有一个新类,在新类中想给form中的控件,如txtbox赋值,怎么办呀。
private const int WM_NCHITTEST = 0x84;
private const int HTCLIENT = 0x1;
private const int HTSIZE = 0x4;
private const int HTCAPTION = 0x2;
private const int WM_SIZING = 532;
private const int HTMINBUTTON = 8;private const int BorderWidth = 5;
//可以调整窗体的大小和移动窗体的位置
protected override void WndProc(ref Message m)
{
switch(m.Msg)
{
case WM_NCHITTEST:
base.WndProc(ref m);
if (DesignMode)
{
return;
} if ((int)m.Result == HTCLIENT)
if ((Cursor.Position.X<=this.Left + BorderWidth) && (Cursor.Position.Y <= this.Top + BorderWidth))
m.Result = (IntPtr)13;//左上
else if ((Cursor.Position.X>=this.Left + this.Width-BorderWidth) && (Cursor.Position.Y<=this.Top +BorderWidth))
m.Result = (IntPtr)14;//右上
else if ((Cursor.Position.X <= this.Left + BorderWidth) && (Cursor.Position.Y>=this.Top + this.Height-BorderWidth))
m.Result = (IntPtr)16;//左下
else if ((Cursor.Position.X>=this.Left + this.Width-BorderWidth) && (Cursor.Position.Y>=this.Top + this.Height-BorderWidth))
m.Result = (IntPtr)17;//右下
else if (Cursor.Position.X<=this.Left + BorderWidth)
m.Result = (IntPtr)10;//左
else if (Cursor.Position.X>=this.Left + this.Width-BorderWidth)
m.Result = (IntPtr)11;//右
else if (Cursor.Position.Y<=this.Top + BorderWidth)
m.Result = (IntPtr)12;//上
else if (Cursor.Position.Y>=this.Top + this.Height-BorderWidth)
m.Result = (IntPtr)15;//下
else
m.Result = (IntPtr)HTCAPTION;//移动窗体
return;
default:
base.WndProc(ref m);
break;
}
}
}