When I do a search through my entire project in visual studio for the word 'clipboard' I find no matches.
Yet somehow my program seems to be changing the contents of my clipboard to be equal to the .text
property of a control on my form. How can this be?
I've identified the handler after which my clipboard always seems to be changed and added a messagebox to get the text from my clipboard to try and identify when it might be changed.
MessageBox.Show(Clipboard.GetText)
Even at the top of the sub handling the event my clipboard has already been changed to the .text
property of a control. This is the only sub which handles this event and the clipboard always changes after this event.
This is a small winforms project written in vb.net.
More information:
My clipboard is getting set to the .text property of a label when I click on it. The labels are made here:
For i = 0 To lstTupChildren.Count - 1
Dim lbl As New Label()
lbl.Size = New System.Drawing.Size(250, 25)
lbl.Font = New System.Drawing.Font("Calibri (body)", 10)
lbl.Text = i + 1 & ". " & lstTupChildren(i).Item1
lbl.Location = New System.Drawing.Point(0, 25 * i)
If lstTupChildren(i).Item3 = True Then lbl.BackColor = Color.GreenYellow Else lbl.BackColor = Color.Orange 'sets the colour depending on whether the timesheet is active'
Me.Controls.Add(lbl)
AddHandler lbl.DoubleClick, AddressOf subChangeTimesheetState 'adds handler for double click to change status
'adds handlers for moving the overlay
AddHandler lbl.MouseDown, AddressOf Form_MouseDown
AddHandler lbl.MouseMove, AddressOf Form_MouseMove
'adds handler for hide context menu'
AddHandler lbl.MouseClick, AddressOf subRightClickMenu
Next
even when I comment out the handler:
AddHandler lbl.DoubleClick, AddressOf subChangeTimesheetState
my clipboard is still changed.
Work around is available here:
Create a new class which inherits the label, vb code:
Public Class myLabel
Inherits Label
Private WM_GETTEXT As Integer = &HD
Private WM_LBUTTONDBLCLK As Integer = &H203
Private doubleclickflag As Boolean = False
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_LBUTTONDBLCLK Then
doubleclickflag = True
End If
If m.Msg = WM_GETTEXT AndAlso doubleclickflag Then
doubleclickflag = False
Return
End If
MyBase.WndProc(m)
End Sub
End Class