From the dynamic form I added. I realized that I can't get a gif animation to run in the form's background. So I thought I'd give it a try by embeding a picturebox on the dynamic form, but it's not working hence why I'm here.
So on my main form (Form1) I have 2 buttons, openfiledialog, and a picturebox. When you click button1 you browse for the an image to display in the picturebox, and when you press button2 as you can see from the code below. It'll open a new form, but what I want is to have the picturebox displayed over the whole form, but also play the gif animation I selected from my main form via Form1 onto the dynamically embeded one, but in the picturebox. Now I can't use it as BackgroundImage so I'm using it as just an Image, but my problem now is I'm unable to move each borderless form, and am unable to close each as well.
Anyway here's my code.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
WidgetForm = New Form()
WidgetForm.ShowInTaskbar = False
WidgetForm.TopMost = True
WidgetForm.FormBorderStyle = Windows.Forms.FormBorderStyle.None
WidgetForm.ContextMenuStrip = ContextMenuStrip2
WidgetForm.Show()
Dim WidgetBG As PictureBox = New PictureBox()
sizew = Me.TextBox1.Text
sizey = Me.TextBox2.Text
WidgetBG.Size = New System.Drawing.Size(sizew, sizey)
WidgetBG.Image = Image.FromFile(Me.OpenFileDialog1.FileName)
WidgetBG.Location = New System.Drawing.Point(0, 0)
WidgetBG.Visible = True
WidgetForm.Controls.Add(WidgetBG)
opac = Me.TextBox3.Text
WidgetForm.Opacity = opac
WidgetForm.Size = New System.Drawing.Size(sizew, sizey)
'Add the event here
AddHandler WidgetBG.MouseDown, AddressOf WidgetBG_MouseDown
AddHandler WidgetBG.MouseMove, AddressOf WidgetBG_MouseMove
AddHandler WidgetBG.MouseUp, AddressOf WidgetBG_MouseUp
AddHandler WidgetBG.DoubleClick, AddressOf WidgetBG_DoubleClick
End Sub
Private Sub WidgetBG_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
If e.Button = Windows.Forms.MouseButtons.Left Then
drag = True
mousex = Windows.Forms.Cursor.Position.X - CType(sender, Form).Left
mousey = Windows.Forms.Cursor.Position.Y - CType(sender, Form).Top
End If
Timer1.Enabled = True
Timer1.Interval = 2500
End Sub
Private Sub WidgetBG_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
If drag Then
CType(sender, Form).Top = Windows.Forms.Cursor.Position.Y - mousey
CType(sender, Form).Left = Windows.Forms.Cursor.Position.X - mousex
End If
End Sub
Private Sub WidgetBG_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Timer1.Enabled = False
drag = False
End Sub
Private Sub WidgetBG_DoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
CType(sender, Form).Close()
End Sub
Any help would be greatly appreciated.