Recently got a WPF, the simplest, a form, with a webbrowser
However, if you use allowtransparency= "True" windowstyle= "None", it is true that the border and native buttons of the form are removed
However, the page opened in WebBrowser is not visible.
Saw a circle of online solutions, basically is that webbrowseroverlay, is really a big pit, a little useless
So find another way, is to use SetWindowLong to solve, of course, allowtransparency and windowsytle to remove
First build a class, such as 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);}
And then in your form code, like 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; Other statements in the form}
This makes the outer window without a native button (maximum minimum off), no border, no border.
Memo with
When when to be!
This article is from the "under the Tree Beast" blog, please make sure to keep this source http://shuxiayeshou.blog.51cto.com/4452347/1767537
WPF de-border conflicts with WebBrowser