从品牌网站建设到网络营销策划,从策略到执行的一站式服务
最近弄了弄WPF,最简单的,一个窗体,里面加个webbrowser
开封网站建设公司成都创新互联,开封网站设计制作,有大型网站制作公司丰富经验。已为开封上千家提供企业网站建设服务。企业网站搭建\外贸网站制作要多少钱,请找那个售后服务好的开封做网站的公司定做!
但是如果用AllowTransparency="True" WindowStyle="None"的话,的确窗体的边框和原生按钮去掉了
但是,webbrowser里打开的页面也看不见了
看了一圈网上的解决办法,基本上都是那个WebBrowserOverlay,真是个大坑,一点不好用
所以找到另一个办法,就是用SetWindowLong来解决,当然AllowTransparency跟WindowSytle都要去掉
首先建一个类,比如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; //窗体中的其它语句 }
这样就完美实现了外窗口无原生按钮(最大最小关闭),无边框,一点边框都没有。
备忘用
当当当当当!
成都网站建设公司地址:成都市青羊区太升南路288号锦天国际A座10层 建设咨询028-86922220
成都快上网科技有限公司-四川网站建设设计公司 | 蜀ICP备19037934号 Copyright 2020,ALL Rights Reserved cdkjz.cn | 成都网站建设 | © Copyright 2020版权所有.
专家团队为您提供成都网站建设,成都网站设计,成都品牌网站设计,成都营销型网站制作等服务,成都建网站就找快上网! | 成都网站建设哪家好? | 网站建设地图