WPF 通过Win32SDK修改窗口样式

时间:2020-05-06 09:16:11   收藏:0   阅读:95
原文:WPF 通过Win32SDK修改窗口样式

使用函数为

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位请参考网页的GetWindowLongPtrASetWindowLongPtrA使用方法不变

原文:https://www.cnblogs.com/lonelyxmas/p/12833955.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!