2010-04-18 29 views
1

我使用的特殊程序,它加载一些网址想象它像自动加载www.google.com窗口 - 程序启动,它加载网站 - 但当你点击一些链接在程序窗口中打开默认浏览器 - 它如何能够在默认浏览器中打开 - 我使用这个代码:System.Uri(“”)在默认浏览器中?

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ 
Partial Class Form1 
Inherits System.Windows.Forms.Form 

<System.Diagnostics.DebuggerNonUserCode()> _ 
Protected Overrides Sub Dispose(ByVal disposing As Boolean) 
    Try 
     If disposing AndAlso components IsNot Nothing Then 
      components.Dispose() 
     End If 
    Finally 
     MyBase.Dispose(disposing) 
    End Try 
End Sub 

Private components As System.ComponentModel.IContainer 
<System.Diagnostics.DebuggerStepThrough()> _ 
Private Sub InitializeComponent() 
    Me.components = New System.ComponentModel.Container 
    Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1)) 
    Me.WB = New System.Windows.Forms.WebBrowser 
    ..... 
    ..... 

Me.WB.Url = New System.Uri("http://www.google.com/", System.UriKind.Absolute) 

使用Visual Basic 2008

+0

引用:在默认浏览器“打开 - 它如何能在默认浏览器中打开“。你需要解决这个问题。 – 2010-04-18 18:23:18

+0

你在程序中打开了一些页面而不是浏览器 - 在那里 - 在程序中点击页面上的某个链接,它会在IE中打开,而不是默认浏览器。 – Hallgaws 2010-04-18 18:29:56

回答

0

如果我正确理解你的问题(让我知道如果我错了),你是问如何在特定的URL上打开系统默认浏览器。这可以这样实现:

Process.Start("http://www.example.com/") 

如果路径存储在一个Uri对象,您将需要使用它的ToString()方法:

Process.Start(someUri.ToString()) 
+0

不...想象一下带有很多按钮和有一个小窗口可以像浏览器一样加载www.example.com - 但它会在程序中打开它,当你点击它的某个链接时 - 我想在默认浏览器中打开 - 希望这是可以理解的... – Hallgaws 2010-04-18 18:25:22

+0

I猜测你必须捕获WebBrowser上的所有点击事件,以某种方式确定点击是否在链接上,然后使用Process.Start()生成单独的浏览器应用程序。 “如何捕获在”WebBrowser“中的链接点击”真的是你问题的关键,然后呢? – 2010-04-18 18:36:43

+0

如果没有比yes更简单的解决方案,那是我的问题... – Hallgaws 2010-04-18 18:40:27