Windows Mobile SDK:如何将标签/按钮变成网站链接?

发布于 2025-01-03 22:58:38 字数 1073 浏览 0 评论 0原文

我正在使用 Visual Basic 在 Windows Mobile SDK 6 中进行编程,我想知道如何使用按钮打开具有特定网站路径的智能手机浏览器(创建链接)

到目前为止,我得到了下一段代码:(

 Public Class GuitarHelperPage
 Public link As New WebBrowser
 Public adress As Uri


 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)    Handles Button1.Click

     adress = New Uri("https://www.google.com")

     Try
         link.Navigate(adress)
         'link.Focus()

     Catch ex As System.UriFormatException
         Return
     End Try

 End Sub

注释'link.Focus()' 它只是我尝试过的东西,但我得到了相同的输出)

我只想单击按钮并在谷歌主页打开浏览器。但是当我单击它时,出现警告“此页面包含安全和不安全的项目。您想继续吗?”出现,当我单击“是”时,没有其他事情发生。

我一直在研究并在 MSDN 帮助页面上找到了这一点:

“WebBrowser 类只能在设置为单线程单元 (STA) 模式的线程中使用。要使用此类,请确保使用 STAThreadAttribute 属性标记您的 Main 方法”

所以我添加了这个我的主要方法:

<STAThread()> _
 Shared Sub Main()

但我仍然收到此错误:“类型 STAThread 未定义。”并且无法找到解决方案,我尝试将相同的属性添加到 Windows 桌面 VB 项目中并且它有效,也许还有另一种方法可以在移动中执行此操作?

我在这个项目中使用.Net Framework 3.5 和 windows mobile sdk 6.0

请帮助,谢谢。

I am programming in Windows Mobile SDK 6 using Visual Basic, i would like to know how to make a button open the smartphone browser with a specific website path (make a link)

I got to the next piece of code so far:

 Public Class GuitarHelperPage
 Public link As New WebBrowser
 Public adress As Uri


 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)    Handles Button1.Click

     adress = New Uri("https://www.google.com")

     Try
         link.Navigate(adress)
         'link.Focus()

     Catch ex As System.UriFormatException
         Return
     End Try

 End Sub

(the commented 'link.Focus()' its just something i tryed out, but i got the same output)

I simply want to click the button and open the browser at google homepage. But when I click it, the warning "This page contains both secure and nonsecure items. Do you want to continue?" appears and when I click "yes", nothing else hapens.

I've been researching and found this on MSDN help pages:

"The WebBrowser class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your Main method is marked with the STAThreadAttribute attribute"

SO i added this my main method:

<STAThread()> _
 Shared Sub Main()

But still i get this error : "Type STAThread is not defined." And can't find a away around, I tried to add this same attribute to a Windows Desktop VB project and it works, maybe there is another way to do it in Mobile?

I am using .Net Framework 3.5 and windows mobile sdk 6.0 for this project

Please help, thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

潦草背影 2025-01-10 22:58:38

如果要打开默认浏览器,则不需要 WebBrowser 控件。只需使用 Process 类,特别是 Start 重载,接受 ProcessStartInfo。将 ProcessStartInfoUseShellExecute 属性设置为 true,以便它将打开默认浏览器(例如,如果用户安装了 Opera Mobile,它将使用该浏览器,而不仅仅是始终强制使用 IE) )。

If you want to open the default browser, you don't need a WebBrowser control. Just use the Process class, specifically the Start overload that takes in a ProcessStartInfo. Set the UseShellExecute property of the ProcessStartInfo to true so that it will open the default browser (e.g. if the user installed Opera Mobile, it will use that, not just always force IE).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文