如何获取 VB Express 8 中 Screens 集合的引用?

发布于 2024-08-23 02:24:37 字数 207 浏览 4 评论 0原文

我直接从 MSDN 尝试过这个示例:

Dim Screens() As System.Windows.Forms.Screens

,但我找不到获取屏幕引用的方法。我检查了我的参考资料,它们看起来不错,但我可能错过了一些东西。有人经历过这个或知道一个错误吗?

编辑 0:如果您使用正确的项目类型,它会有所帮助。在 WPF 中,它是系统参数。谢谢大家。

I've tried this example directly from MSDN:

Dim Screens() As System.Windows.Forms.Screens

and I can't find a way to get a reference to the Screen. I've checked my references and they seem fine but I may have missed something. Anyone experience this or know of a bug?

EDIT 0: It helps if you're using the correct project type. In WPF, it's SystemParameters. Thanks all.

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

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

发布评论

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

评论(1

多孤肩上扛 2024-08-30 02:24:38

我相当确定您确实想要

Dim Screens() As System.Windows.Forms.Screen

(末尾没有 s),因为没有 Screens 类型。上面的行将 Screens 声明为 Screen 对象的数组 - 现在您可以

Screens = System.Windows.Forms.Screen.AllScreens

对每个 Screen 执行您想要执行的任何操作。

编辑不确定您仍然遇到什么参考问题。从头开始,我启动了一个新的 Windows 窗体项目,将 Form1 中的代码隐藏替换为:

Public Class Form1

    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        Dim Screens() As System.Windows.Forms.Screen
        Screens = System.Windows.Forms.Screen.AllScreens

        For Each s As Screen In Screens
            MessageBox.Show(s.DeviceName)
        Next

    End Sub
End Class

它运行并执行我期望的操作。这是 VS2005(不是 Express),但我无法想象这会有什么不同。

I'm fairly sure you actually want

Dim Screens() As System.Windows.Forms.Screen

(no s at the end), as there isn't a Screens type. The above line declares Screens as an array of Screen objects - now you can do

Screens = System.Windows.Forms.Screen.AllScreens

and do whatever it is you want to do with each Screen.

edit not sure what reference problem you are still getting. From scratch, I start a new Windows Forms project, replace the code-behind in Form1 with this:

Public Class Form1

    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        Dim Screens() As System.Windows.Forms.Screen
        Screens = System.Windows.Forms.Screen.AllScreens

        For Each s As Screen In Screens
            MessageBox.Show(s.DeviceName)
        Next

    End Sub
End Class

and it runs and does what I expect. This is VS2005 (not Express) but I can't imagine that would make a difference.

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