C WinForm 改變無邊框窗體尺寸

2021-06-27 05:57:32 字數 784 閱讀 6490

c# 透明winform上建立了自定義邊框後,需要拖動自定義邊框達到改變窗體尺寸的效果。使用了很多方法發現有些**只能橫向拉伸,有些**會造成無法拖動。

最後才找到這個切實可行的辦法。

const int guying_htleft = 10;

const int guying_htright = 11;

const int guying_httop = 12;

const int guying_httopleft = 13;

const int guying_httopright = 14;

const int guying_htbottom = 15;

const int guying_htbottomleft = 0x10;

const int guying_htbottomright = 17;

protected override void wndproc(ref message m)

}

注意點:窗體內所有物件必須將邊框保留出來,不然就無法拖動,比如將statusbar設定duck為bottom,此時元素與底部沒有空隙即看不到form的邊框。

如圖所以就無法拖動。如果要可以拖動就必須使元素與窗體邊緣保持一定距離如下,就可以。

C Winform 無邊框拖動窗體

一 無邊框拖動窗體 當設定窗體的formboderstyle為null時,系統自帶的窗體拖拽屬性就失效了,需要自己寫這一部分。在這個工具裡博主曹勇panel控制項當作窗體的頭部,因此實現窗體拖拽也就是實現拖拽panel時窗體位置發生變化,如下 首先引入系統api dllimport user32.d...

無邊框窗體拖動和改變大小

const int htleft 10 const int htright 11 const int httop 12 const int httopleft 13 const int httopright 14 const int htbottom 15 const int htbottomlef...

拖動無邊框窗體

frm main.cs 1 using system 2using system.collections.generic 3using system.componentmodel 4using system.data 5using system.drawing 6using system.linq ...