最近弄了弄WPF,最簡單的,一個窗體,里面加個webbrowser
開封網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián),開封網(wǎng)站設(shè)計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗。已為開封上千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站制作要多少錢,請找那個售后服務(wù)好的開封做網(wǎng)站的公司定做!
但是如果用AllowTransparency="True" WindowStyle="None"的話,的確窗體的邊框和原生按鈕去掉了
但是,webbrowser里打開的頁面也看不見了
看了一圈網(wǎng)上的解決辦法,基本上都是那個WebBrowserOverlay,真是個大坑,一點不好用
所以找到另一個辦法,就是用SetWindowLong來解決,當(dāng)然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; //窗體中的其它語句 }
這樣就完美實現(xiàn)了外窗口無原生按鈕(最大最小關(guān)閉),無邊框,一點邊框都沒有。
備忘用
當(dāng)當(dāng)當(dāng)當(dāng)當(dāng)!
網(wǎng)站欄目:WPF去邊框與webbrowser的沖突
鏈接URL:http://aaarwkj.com/article42/jjhsec.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供、全網(wǎng)營銷推廣、關(guān)鍵詞優(yōu)化、企業(yè)建站、靜態(tài)網(wǎng)站、搜索引擎優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)