none
WebBrowser打开别的窗体就事件失效,这是怎么回事。 RRS feed

  • 问题

  • 应该不是系统问题 测试了WIN7 WIN2003都这样。

     

    Private Sub HtmlEditor_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
    
     WebBrowser1.Navigate(New Uri("http://www.baidu.com"))
     End Sub
    
     Private Sub WebBrowser1_LoadCompleted(ByVal sender As Object, ByVal e As System.Windows.Navigation.NavigationEventArgs) Handles WebBrowser1.LoadCompleted
    
    
    
     AddHandler CType(WebBrowser1.Document, mshtml.HTMLDocumentEvents_Event).oncontextmenu, Function() False
    
     AddHandler CType(WebBrowser1.Document, mshtml.HTMLDocumentEvents_Event).onmouseup, Sub()                                                MsgBox("点击")                                              End Sub
    
     End Sub
    
    
    
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
    
     System.Diagnostics.Process.Start("c:\")
    
     End Sub
    
    
    
    
    
    <Window x:Class="MainWindow"
    
    
    
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    
    
    
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    
    
    
     Title="MainWindow" Height="350" Width="525">
    
    
    
     <Grid>
    
    
    
     <WebBrowser Name="WebBrowser1" Margin="0,48,0,0"></WebBrowser>
    
    
    
     <Button Content="打开C盘,就丢失事件" Height="23" HorizontalAlignment="Left" Margin="12,12,0,0" Name="Button1" VerticalAlignment="Top" />
    
    
    
     <Label Content="这是怎么回事WebBrowser事件丢失" HorizontalAlignment="Left" Margin="146,18,0,0" VerticalAlignment="Top" />
    
    
    
     </Grid>
    
    
    
    </Window>
    
    
    2010年9月7日 17:05