'First attempt mouse events' This only turns PB2 to Blue but PB1 is still Blue also but i want it to be Green.
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
Debug.Print("PB1_MouseDown")
pbControlDn = 1
Debug.Print("1")
pbControlDnColor = PictureBox1.BackColor
Debug.Print(pbControlDnColor.ToString)
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
Debug.Print("PB1_MouseMove")
If pbControlDn > 0 Then
pbControlUp = 1
Debug.Print("1")
pbControlUpColor = PictureBox1.BackColor
Debug.Print(pbControlUpColor.ToString)
End If
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
Debug.Print("PB1_MouseUp")
Select Case pbControlUp
Case 1
Debug.Print(pbControlUpColor.ToString)
Debug.Print(pbControlDnColor.ToString)
PictureBox1.BackColor = pbControlUpColor
PictureBox2.BackColor = pbControlDnColor
PictureBox1.Refresh()
PictureBox2.Refresh()
Case 2
Case Else
End Select
pbControlDn = 0
pbControlUp = 0
End Sub
Private Sub PictureBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseDown
Debug.Print("PB2_MouseDown")
pbControlDn = 2
Debug.Print("2")
pbControlDnColor = PictureBox2.BackColor
Debug.Print(pbControlDnColor.ToString)
End Sub
Private Sub PictureBox2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseMove
Debug.Print("PB2_MouseMove")
If pbControlDn > 0 Then
pbControlUp = 2
Debug.Print("2")
pbControlUpColor = PictureBox2.BackColor
Debug.Print(pbControlUpColor.ToString)
End If
End Sub
Private Sub PictureBox2_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseUp
Debug.Print("PB2_MouseUp")
Select Case pbControlUp
Case 1
Case 2
Debug.Print(pbControlUpColor.ToString)
Debug.Print(pbControlDnColor.ToString)
PictureBox2.BackColor = pbControlUpColor
PictureBox1.BackColor = pbControlDnColor
PictureBox1.Refresh()
PictureBox2.Refresh()
Case Else
End Select
pbControlDn = 0
pbControlUp = 0
End Sub
'Second attempt dodragdrop' does nothing
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
Dim PB1 As PictureBox = CType(sender, PictureBox)
PB1.DoDragDrop(PB1.BackColor, DragDropEffects.Copy)
End Sub
Private Sub PictureBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragEnter
If e.Data.GetDataPresent(DataFormats.Bitmap) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub PictureBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragDrop
Dim picbox As PictureBox = CType(sender, PictureBox)
Dim g As Color = picbox.BackColor
PictureBox1.BackColor = g
'g.DrawImage(CType(e.Data.GetData(DataFormats.Bitmap), Image), New Point(0, 0))
End Sub
Private Sub PictureBox2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseDown
Dim PB1 As PictureBox = CType(sender, PictureBox)
PB1.DoDragDrop(PB1.BackColor, DragDropEffects.Copy)
End Sub
Private Sub PictureBox2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox2.DragEnter
If e.Data.GetDataPresent(DataFormats.Bitmap) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub PictureBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox2.DragDrop
Dim picbox As PictureBox = CType(sender, PictureBox)
Dim g As Color = picbox.BackColor
PictureBox2.BackColor = g
'g.DrawImage(CType(e.Data.GetData(DataFormats.Bitmap), Image), New Point(0, 0))
End Sub