积极答复者
WPF窗体可以最大化最小化,但窗体不可拉伸,如何实现?

问题
答案
-
使用Win32SDK即可
注册函数
[DllImport("user32.dll", EntryPoint = "GetWindowLong")] public static extern int GetWindowLong(IntPtr hwnd, int nIndex); [DllImport("user32.dll", EntryPoint = "SetWindowLong")] public static extern int SetWindowLong(IntPtr hMenu, int nIndex, int dwNewLong);
使用函数
private void DisableSizebox() { int GWL_STYLE = -16; int WS_THICKFRAME = 0x00040000; IntPtr handle = new WindowInteropHelper(this).Handle; int nStyle = GetWindowLong(handle, GWL_STYLE); nStyle &= ~WS_THICKFRAME; SetWindowLong(handle, GWL_STYLE,nStyle); }
- 已建议为答案 Yong LuMicrosoft contingent staff, Moderator 2019年8月21日 2:00
- 已标记为答案 VuVl 2019年8月21日 15:11
全部回复
-
使用Win32SDK即可
注册函数
[DllImport("user32.dll", EntryPoint = "GetWindowLong")] public static extern int GetWindowLong(IntPtr hwnd, int nIndex); [DllImport("user32.dll", EntryPoint = "SetWindowLong")] public static extern int SetWindowLong(IntPtr hMenu, int nIndex, int dwNewLong);
使用函数
private void DisableSizebox() { int GWL_STYLE = -16; int WS_THICKFRAME = 0x00040000; IntPtr handle = new WindowInteropHelper(this).Handle; int nStyle = GetWindowLong(handle, GWL_STYLE); nStyle &= ~WS_THICKFRAME; SetWindowLong(handle, GWL_STYLE,nStyle); }
- 已建议为答案 Yong LuMicrosoft contingent staff, Moderator 2019年8月21日 2:00
- 已标记为答案 VuVl 2019年8月21日 15:11