none
Screen 2 Form 2 Video failure RRS feed

  • Question

  • I'm using duel screen pc and i want to display 2 forms each screen.

    I used below codes for that.

    Dim screen As Screen
            screen = Screen.AllScreens(1)
            Form2.StartPosition = FormStartPosition.Manual
            Form2.Location = screen.Bounds.Location + New Point(100, 100)
            Form2.Show()

    This is worked fine until I put video player on form 2.

    if i put full screen image its works well. but i want to show some videos on my second screen. 

    if i try to add windows media player on form2 then its not opening on 2nd screen. its just open in first screen.

    Could you help me with this?

    Saturday, March 24, 2018 11:21 AM

Answers

  •  Thanks for your replay.

    I tried this but not working form me. But If I remove Full screen then that's possible to run on both screen.

    Thanks again

    Tuesday, March 27, 2018 12:43 AM

All replies

  •  There are several reasons it may not be working for you.  The first thing I would recommend is to turn Option Strict on so that it will show you any Type conversion errors such as where you are adding a Point to the screen's Location.  That should be a Size,  not a Point.

      Also,  the Screens are not always in an order such as 0=Primary and 1=Secondary.  They can be in any order such as the Primary screen being at index 1 and the secondary screen being at index 0.  A little better way to find the secondary screen would be to look for the first screen that is not the Primary screen as shown below.

     You should also be using a new instance of Form2,  not the default instance.  This is also shown below.

     This example opens Form1 on the Primary screen and when Button1 is clicked,  it opens a new instance of Form2 on the secondary screen.  You can try implementing something similar to this example in your application.

    Form1 code.  Requires 1 Button on the Form.

    Option Strict On
    Option Explicit On
    Option Infer Off

    Public Class Form1
        Public WithEvents VideoForm As Form2 = Nothing

        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            If VideoForm Is Nothing Then
                VideoForm = New Form2
                VideoForm.StartPosition = FormStartPosition.Manual
                Dim scrn As Screen = Screen.AllScreens.Where(Function(x) Not x.Primary).FirstOrDefault 'find the first screen that is not the Primary screen
                VideoForm.Location = scrn.Bounds.Location + New Size(100, 100) 'you can only add a Size type like this,  not a Point type
                VideoForm.Show()
                VideoForm.LoadVideo("C:\Test\Vids\TestingVideo.avi")
            End If
        End Sub

        Private Sub VideoForm_Closed(sender As Object, e As EventArgs) Handles VideoForm.Closed
            VideoForm = Nothing
        End Sub
    End Class
     

     Form2 code.  Requires 1 AxWindowsMediaPlayer control added to the form.

    Public Class Form2
        Public Sub LoadVideo(filename As String)
            AxWindowsMediaPlayer1.URL = filename
        End Sub
    End Class


    If you say it can`t be done then i`ll try it

    Saturday, March 24, 2018 12:06 PM
  •  Thanks for your replay.

    I tried this but not working form me. But If I remove Full screen then that's possible to run on both screen.

    Thanks again

    Tuesday, March 27, 2018 12:43 AM