wmp uimode = "none" ?

ud2008

Well-known member
Joined
Jul 5, 2010
Messages
148
Programming Experience
Beginner
I know it's been a while since the last post.

But I've been working on the app, now I create the second form dynamically, the windows media player component is added to the form (this works), but I want the uimode to be none, I use this code for it, but then I get an error.

Here is the code to create the form and wmp dynamically:
VB.NET:
Imports AxWMPLib

Public Class MainForm

    Dim tinseconden As Integer
    Dim musiclocation As New ArrayList
    Dim form2 As New Form
    Dim screen As Screen
    Dim media As New AxWMPLib.AxWindowsMediaPlayer

    Private Sub ButtonItem2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItem2.CheckedChanged
        If screen.AllScreens.Length > 1 Then
            If ButtonItem2.Checked = True Then
                form2.Controls.Add(media)
                'Show second form on second screen
                screen = screen.AllScreens(1)
                'form2.ShowInTaskbar = False
                form2.StartPosition = FormStartPosition.Manual
                form2.Location = screen.Bounds.Location + New Point(100, 100)
                form2.WindowState = FormWindowState.Maximized
                form2.FormBorderStyle = Windows.Forms.FormBorderStyle.None
                media.uiMode = "none"
                media.Dock = DockStyle.Fill
                form2.Show()
            Else
                ButtonItem2.Checked = False
                form2.Hide()
                media.Ctlcontrols.stop()
                AxWindowsMediaPlayer1.Ctlcontrols.stop()
                Play.Enabled = False
                Pause.Enabled = False
                Stopbutton.Enabled = False
                If CheckBox1.Checked = True Then
                    CheckBox1.Checked = False
                    CheckBox1.Enabled = False
                End If
            End If
        Else
            MsgBox("No extended screen found, dual video needs an extended screen.")
            ButtonItem2.Checked = False
            media.Ctlcontrols.stop()
            AxWindowsMediaPlayer1.Ctlcontrols.stop()
            Play.Enabled = False
            Pause.Enabled = False
            Stopbutton.Enabled = False
            If CheckBox1.Checked = True Then
                CheckBox1.Checked = False
                CheckBox1.Enabled = False
            End If
            form2.Close()
        End If
    End Sub
End Class

And here the error (on this line: media.uiMode = "none"):
VB.NET:
Exception of type 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown.

Thanks
 
Back
Top