双击.NET Label控件拷贝它到剪贴板在Vista +文字? [英] Double-clicking .NET Label control copies its text to clipboard on Vista+?

查看:250
本文介绍了双击.NET Label控件拷贝它到剪贴板在Vista +文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我通过我在Visual Studio中的单词剪贴板整个项目做一个搜索我找不到匹配。

When i do a search through my entire project in visual studio for the word 'clipboard' i find no matches.

然而,不知我的计划似乎正在改变我的剪贴板中的内容等于在我的表单控件的属性的.text。这怎么可能?

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)

即使在子处理我的剪贴板已经改变为控制的的.text财产事件的顶部。这是处理该事件,剪贴板此事件后总是变化的唯一子。

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.

这是写在vb.net小WinForms项目。

This is a small winforms project written in vb.net.

详细信息:

我的剪贴板是越来越设置为当我点击它的标签的的.text属性。标签在这里做:

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

甚至当我注释掉的处理程序:     AddHandler的lbl.DoubleClick,AddressOf subChangeTimesheetState

even when i comment out the handler: AddHandler lbl.DoubleClick, AddressOf subChangeTimesheetState

我的剪贴板仍会被改变。

my clipboard is still changed.

解决方法是可以在这里找到:工作在这里:<一href="http://www.aspnet-answers.com/microsoft/NET-WinForms-Controls/32231136/double-click-label-and-its-text-appears-on-the-clipboard.aspx" rel="nofollow">http://www.aspnet-answers.com/microsoft/NET-WinForms-Controls/32231136/double-click-label-and-its-text-appears-on-the-clipboard.aspx

Work around is available here: Work around here: http://www.aspnet-answers.com/microsoft/NET-WinForms-Controls/32231136/double-click-label-and-its-text-appears-on-the-clipboard.aspx

创建一个新的类继承的标签,VB code:

Create a new class which inherits the label, vb code:

公共类myLabel

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

末级

推荐答案

这不是你的code,这是一个功能在Windows Vista中引入。

It's not your code, it's a "feature" introduced in Windows Vista.

在Windows Vista中,Windows外壳程序的程序员在变化检查(无规格/理由的变更),改变默认的标签控件到文本复制到剪贴板时,双击。

In Windows Vista, a Windows Shell programmer checked in a change (with no spec/justification in the changelist) that changed the default label control to copy its text to the clipboard when double-clicked.

这个变化通常不会影响C ++应用程序,由于它们是如何创建/主机标签控件,但它会影响所有VS.NET应用。我提出一个bug反对(惊讶)框架队的时候我在Win7的时间内发现了这一点,但他们害怕修复bug,因为它已经present了这么久。

This change typically doesn't impact C++ applications due to how they create/host the label control, but it impacts all VS.NET applications. I filed a bug against the (surprised) Framework team when I discovered this in the Win7 timeframe, but they were scared to fix the bug because it had been present for so long.

下面是重复的<一个href="http://stackoverflow.com/questions/2519587/is-there-any-way-to-disable-the-double-click-to-copy-functionality-of-a-net-l">Is有什么办法禁用&QUOT;双击复制&QUOT;一个.NET标签的功能?

这篇关于双击.NET Label控件拷贝它到剪贴板在Vista +文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆