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 mis开发者_运维知识库sed 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.
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.
精彩评论