双显示器屏幕保护程序失败

时间:2013-11-29 11:51:09

标签: vb.net screensaver multiple-monitors

我正在尝试制作双屏幕屏幕保护程序。它起初工作,但现在它无法正常工作。这是启动功能:

Sub Main()
    Dim x = 0
    For Each screen As Screen In screen.AllScreens
        Dim screensaver As ScrSav = New ScrSav(screen.Bounds)
        screensaver.Location = screen.Bounds.Location
        screensaver.Show()
        x += 1
        Debug.Print(screen.Bounds.Left & " " & screen.Bounds.Top & " " & screen.Bounds.Width & " " & screen.Bounds.Height & " " & "")
    Next
    Application.Run()
End Sub

这是表单代码

Public Class ScrSav
Public Sub New()
    InitializeComponent()
End Sub
Public Sub New(xBounds As Rectangle)
    InitializeComponent()
    Me.Bounds = xBounds
    Debug.Print(Me.Bounds.Left & " " & Me.Bounds.Top & " " & Me.Bounds.Width & " " & Me.Bounds.Height & " " & "")
    Cards.Location = New Point((Me.Width - Cards.Width) / 2, (Me.Height - Cards.Height) / 2)
    Header.Location = New Point((Me.Width - Header.Width) / 2, 0)
    Cards.Navigate("http://pah.guycothal.com/screensaver.aspx")
End Sub
Protected Overrides Sub Finalize()
    MyBase.Finalize()
    End
End Sub
Private Sub ScrSav_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
    End
End Sub

结束班

我做错了什么??? 我正在按照其他人的方式初始化2个屏幕。事实上,我有几个地方我已经调试到位,看看每个潜艇中发生了什么。这是什么输出

   0    0 1280 800 <--main
   0    0 1280 800 <--new
1280 -224 1280 1024 <-main
1280 -224 1280 1024 <-new

我已经标记了每个来自哪个sub,以便更容易理解。此外,这是表格本身的内容

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

'Form overrides dispose to clean up the component list.
<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

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.  
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
    Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(ScrSav))
    Me.Cards = New System.Windows.Forms.WebBrowser()
    Me.Header = New System.Windows.Forms.PictureBox()
    CType(Me.Header, System.ComponentModel.ISupportInitialize).BeginInit()
    Me.SuspendLayout()
    '
    'Cards
    '
    Me.Cards.AllowNavigation = False
    Me.Cards.AllowWebBrowserDrop = False
    Me.Cards.IsWebBrowserContextMenuEnabled = False
    Me.Cards.Location = New System.Drawing.Point(128, 137)
    Me.Cards.MaximumSize = New System.Drawing.Size(640, 200)
    Me.Cards.MinimumSize = New System.Drawing.Size(640, 200)
    Me.Cards.Name = "Cards"
    Me.Cards.ScriptErrorsSuppressed = True
    Me.Cards.ScrollBarsEnabled = False
    Me.Cards.Size = New System.Drawing.Size(640, 200)
    Me.Cards.TabIndex = 0
    Me.Cards.TabStop = False
    Me.Cards.Url = New System.Uri("http://pah.guycothal.com/screensaver.aspx", System.UriKind.Absolute)
    Me.Cards.WebBrowserShortcutsEnabled = False
    '
    'Header
    '
    Me.Header.Image = CType(resources.GetObject("Header.Image"), System.Drawing.Image)
    Me.Header.InitialImage = CType(resources.GetObject("Header.InitialImage"), System.Drawing.Image)
    Me.Header.Location = New System.Drawing.Point(0, 0)
    Me.Header.MaximumSize = New System.Drawing.Size(2000, 60)
    Me.Header.MinimumSize = New System.Drawing.Size(2000, 60)
    Me.Header.Name = "Header"
    Me.Header.Size = New System.Drawing.Size(2000, 60)
    Me.Header.TabIndex = 1
    Me.Header.TabStop = False
    '
    'ScrSav
    '
    Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
    Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
    Me.BackColor = System.Drawing.Color.Black
    Me.ClientSize = New System.Drawing.Size(991, 453)
    Me.Controls.Add(Me.Header)
    Me.Controls.Add(Me.Cards)
    Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
    Me.Name = "ScrSav"
    Me.ShowInTaskbar = False
    Me.Text = "ScrSav"
    Me.TopMost = True
    Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
    CType(Me.Header, System.ComponentModel.ISupportInitialize).EndInit()
    Me.ResumeLayout(False)

End Sub
Friend WithEvents Cards As System.Windows.Forms.WebBrowser
Friend WithEvents Header As System.Windows.Forms.PictureBox
End Class

0 个答案:

没有答案