首页 > Windows开发 > 详细

WPF去边框与webbrowser的冲突

时间:2017-01-05 21:20:12      阅读:250      评论:0      收藏:0      [点我收藏+]

首先建一个类,比如NativeMethods.cs

class NativeMethods{
    public const int WS_CAPTION=0x00C0000;
    public const int WS_BORDER=0x00800000;
    public const int WS_DLGFRAME=0x00400000;
    public const int GWL_STYLE=-16;
    [DllImport("user32", EntryPoint="GetWindowLong")]
    public static extern int GetWindowLong(IntPtr handle, int sytle);
    [DllImport("user32", EntryPoint="SetWindowLong")]
    public static extern int SetWindowLong(IntPtr handle, int oldStyle, int new Style);
}

然后在你的窗体代码中,比如MainWindow.xaml.cs

public partial class MainWindow : Window{
    IntPtr hwnd=new System.Windows.Interop.WindowInteropHelper(this).Handle;
    int oldStyle=NativeMethods.GetWindowLong(hwnd,NativeMethods.GWL_STYLE);
    NativeMethods.SetWindowLong(hwnd,NativeMethods.GWL_STYLE,oldStyle&~NativeMethods.WS_BORDER&~NativeMethods.WS_CAPTION&~NativeMethods.WS_DLGFRAME);
}

public MainWindow(){
    InitializeComponent();
    this.Loaded+=Window_Loaded;
    //窗体中的其它语句
}


这样就完美实现了外窗口无原生按钮(最大最小关闭),无边框,一点边框都没有。

WPF去边框与webbrowser的冲突

原文:http://www.cnblogs.com/baiyangtree/p/6253703.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!