5

WebBrowser コントロールを含むウィンドウを表示しています。ウィンドウをフレームレスにしたいので、WindowStyle="None" を設定しました。これは機能しますが、ウィンドウの周りに色付きの境界線が表示されます。allowstransparency="true" はこれを削除しますが、WebBrowser は表示されなくなります (ボタンは表示されます)。

http://www.neowin.net/forum/topic/646970-c%23-wpf-window-with-transparency-makes-windowsformshost-disappear/を見つけましたが、動作させることができません (SetWindowsLong パラメータ エラー)

Window x:Class="ZoomBrowserWPF.WebWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:UMenu"
        Title="Test" Height="605" Width="700" ResizeMode="CanResizeWithGrip"
        Loaded="Window_Loaded" Unloaded="Window_Unloaded"
        WindowStyle="None"        
        Background="Transparent"              
        Left="1" Top="1"
        UseLayoutRounding="True" SizeChanged="Window_SizeChanged" >
    <Border Name="WindowBorder"  BorderBrush="Black" BorderThickness="1" CornerRadius="10"     Background="Beige">
    <Grid>        
        <Grid.RowDefinitions>
            <RowDefinition Height="25"/>
            <RowDefinition Height="30"/>
            <RowDefinition/>
            <RowDefinition Height="33"/>
            <RowDefinition Height="25.5"/>
        </Grid.RowDefinitions>
        <Grid x:Name="GridWebBrowser" Grid.Row="2" Grid.RowSpan="2">            
            <WebBrowser x:Name="webBrowser"  Grid.ColumnSpan="2" Visibility="Visible"
                         Margin="0,0,-16,0" 
                        ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
                        ScrollViewer.VerticalScrollBarVisibility="Auto" 
                        ScrollViewer.IsDeferredScrollingEnabled="False"
                        ScrollViewer.CanContentScroll="False"
                        />
        </Grid>
        <Button x:Name="btnZoomIn" Content="Zoom in" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="12,0,0,0"  VerticalAlignment="Top" Width="75" Click="btnZoomIn_Click" />
        <Button x:Name="btnZoomOut" Content="Zoom out" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="168,0,0,0"  VerticalAlignment="Top" Width="75" Click="btnZoomOut_Click" />
        <TextBlock Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="102,0,0,0" Name="txtZoom" Text="100" VerticalAlignment="Top" Width="60" />
    </Grid>
    </Border>
</Window>
4

6 に答える 6

10

これは古い質問であることは知っていますが、今日まったく同じ問題があり、使用して解決しました

ResizeMode="NoResize"

それ以外の

Allowstransparency="true"

ResizeMode は注釈境界も削除し、WebBrowser コントロールには影響しません。この場合、問題を解決する最も簡単な方法のようです:)

于 2014-10-15T11:07:44.270 に答える
5

WebBrowser コントロールは実際には WPF コントロールではないため、WPF のトリックでは機能しません。これはラップされた ActiveX IE Web ブラウザー コントロールであり、WPF によってレンダリングされません。

おそらく、あなたの問題は、この投稿WebBrowser コントロールからの境界線の削除に関連しています。

正直なところ、可能であれば、このひどい WebControl を放棄して、別のものを使用してみてください。Awesomium.NET、CefSharp、または CefGlue.NET (すべて Chromium ベース) など、適切な WPF サポートを備えた無料の代替手段があります。

于 2013-10-18T08:15:15.163 に答える
0

あなたが投稿したソースを見たところ、うまくいきました。コードは次のとおりです。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace PAUL.Allgemein.Seiten
{
/// <summary>
/// Interaktionslogik für Robbe.xaml
/// </summary>
public partial class Robbe : Window
{
    #region The Classic Window API
    //The SendMessage function sends a message to a window or windows.
    [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
    static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);

    //ReleaseCapture releases a mouse capture
    [DllImportAttribute("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
    public static extern bool ReleaseCapture();

    //SetWindowLong lets you set a window style
    [System.Runtime.InteropServices.DllImport("user32.dll")]
    static extern int SetWindowLong(IntPtr hWnd, int nIndex, long dwNewLong);
    #endregion

    const int GWL_STYLE = -16;
    const long WS_POPUP = 2147483648;

    //private const int GWL_STYLE = -16;
    //private const int WS_SYSMENU = 0x80000;
    //[DllImport("user32.dll", SetLastError = true)]
    //private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
    //[DllImport("user32.dll")]
    //private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
    public Robbe()
    {

        InitializeComponent();
    }

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        IntPtr hWnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;
        SetWindowLong(hWnd, GWL_STYLE, WS_POPUP);
    }
}
}

および Xaml コード:

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Robbe" Height="300" Width="300"
    Loaded="Window_Loaded">
<Grid>
    <!-- Creates the shadow on the right and bottom -->
    <Border Focusable="False" BorderBrush="Gray"           
        BorderThickness="0,0,2,2"
        CornerRadius="10"
        Background="Beige" >
        <WebBrowser Source="C:\Users\nicholas\Desktop\puale\PAUL\bin\Debug\robbe.swf" Margin="62,71,69,56"></WebBrowser>
    </Border>
</Grid>

于 2013-11-20T11:41:49.800 に答える