none
WPF窗体可以最大化最小化,但窗体不可拉伸,如何实现? RRS feed

答案

  • 使用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);
            }

    2019年8月21日 1:10
  • 在loaded的方法就可以了
    • 已标记为答案 VuVl 2019年8月21日 15:11
    2019年8月21日 13:54

全部回复

  • 使用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);
            }

    2019年8月21日 1:10
  • 我应该把方法放到哪里,在窗口打开时就调用方法。
    2019年8月21日 8:28
  • 在loaded的方法就可以了
    • 已标记为答案 VuVl 2019年8月21日 15:11
    2019年8月21日 13:54