static class safenativemethods
protected override void onmousedown(mousebuttoneventargs e)
拖動protected override void wndproc(ref message m)
return;
case 0x84:
base.wndproc(ref m);
point lpint = new point((int)m.lparam);
lpint.offset(-this.left, -this.top);
point lpint1 = new point((int)m.lparam);
lpint1.offset(-this.right, -this.bottom);
// 設定可托動的區域
rectangle client = new rectangle(0, 3, this.width, 25);
if (client.contains(lpint))
//上rectangle topboder = new rectangle(5, 0, this.width - 10, 5);
if (topboder.contains(lpint))
//下rectangle downboder = new rectangle(-this.width, -3, this.width, 3);
if (downboder.contains(lpint1))
//左rectangle leftboder = new rectangle(0, 5, 5, this.height - 10);
if (leftboder.contains(lpint))
//右rectangle rightboder = new rectangle(-3, -this.height, 3, this.height);
if (rightboder.contains(lpint1))
//下right角
rectangle rightdownboder = new rectangle(-6, -6, 30, 10);
if (rightdownboder.contains(lpint1))
左下rectangle leftdownboder = new rectangle(0, -10, 30, 10);
if (leftdownboder.contains(lpint1))
左上rectangle leftupboder = new rectangle(0, 0, 30, 10);
if (leftupboder.contains(lpint1))
//右上
rectangle rightupboder = new rectangle(-6, -this.height, 30, 10);
if (rightupboder.contains(lpint1))
return;
}base.wndproc(ref m);
}
拖動無邊框窗體
frm main.cs 1 using system 2using system.collections.generic 3using system.componentmodel 4using system.data 5using system.drawing 6using system.linq ...
C Winform 無邊框拖動窗體
一 無邊框拖動窗體 當設定窗體的formboderstyle為null時,系統自帶的窗體拖拽屬性就失效了,需要自己寫這一部分。在這個工具裡博主曹勇panel控制項當作窗體的頭部,因此實現窗體拖拽也就是實現拖拽panel時窗體位置發生變化,如下 首先引入系統api dllimport user32.d...
WPF無邊框拖動 全屏 縮放
先看效果 無邊框設定windowstyle none 視窗無關閉及縮放按鈕,但還有黑邊 設定allowstransparency true 黑邊沒有了。全屏,遮住工作列 this.windowstate system.windows.windowstate.normal this.windowsty...