使用函数为
SetWindowLong
GetWindowLong
注册函数
[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); }
注意 启用窗口样式为
nStyle|=WS_THICKFRAME
如果是多个样式启用或者禁止为
//禁用 nStyle &= ~WS_CAPTION&~WS_MINIMIZEBOX; //启用 nStyle |= WS_MAXIMIZEBOX| WS_CAPTION;
具体样式请参考具体Windows Style
注意:msdn中均为Long型,去掉L即可为int,
本函数均为32位,对应64位请参考网页的GetWindowLongPtrA,SetWindowLongPtrA使用方法不变
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/12637.html