title: Double-clicking .NET Label control copies its text to clipboard on Vista+?
body: <p>When i do a search through my entire project in visual studio for the word 'clipboard' i find no matches. </p>
  
  <p>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?</p>
  
  <p>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. </p>
  
  <pre><code>MessageBox.Show(Clipboard.GetText)
  </code></pre>
  
  <p>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. </p>
  
  <p>This is a small winforms project written in vb.net.</p>
  
  <p>More information:</p>
  
  <p>My clipboard is getting set to the .text property of a label when i click on it. The labels are made here:</p>
  
  <pre><code>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 &amp; ". " &amp; 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
  </code></pre>
  
  <p>even when i comment out the handler:
      AddHandler lbl.DoubleClick, AddressOf subChangeTimesheetState</p>
  
  <p>my clipboard is still changed.</p>
  
  <p>Work around is available here: Work around here: <a href="http://www.aspnet-answers.com/microsoft/NET-WinForms-Controls/32231136/double-click-label-and-its-text-appears-on-the-clipboard.aspx" rel="noreferrer">http://www.aspnet-answers.com/microsoft/NET-WinForms-Controls/32231136/double-click-label-and-its-text-appears-on-the-clipboard.aspx</a></p>
  
  <p>Create a new class which inherits the label, vb code:</p>
  
  <p>Public Class myLabel</p>
  
  <pre><code>Inherits Label
  Private WM_GETTEXT As Integer = &amp;HD
  Private WM_LBUTTONDBLCLK As Integer = &amp;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
  </code></pre>
  
  <p>End Class</p>