WPF de-border conflicts with WebBrowser

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.