Discussion:
Double click label and its text appears on the clipboard
(too old to reply)
SMJT
2008-05-20 15:44:10 UTC
Permalink
Hi

Has anyone noticed that if you double click a label, the text of that
label appears on the clipboard? If so, how do I stop this from
happening?

I'm running VS 2008 on a Vista box. I get the same behaviour on
another Vista machine but not on XP machines so I'm pretty sure my VS
installation is okay but just need to check.

Thanks in advance
Herfried K. Wagner [MVP]
2008-05-20 22:09:14 UTC
Permalink
Post by SMJT
Has anyone noticed that if you double click a label, the text of that
label appears on the clipboard? If so, how do I stop this from
happening?
Yes, I am able to reproduce this behavior. However, I am not sure if it is
by design or not.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
SMJT
2008-05-21 07:26:46 UTC
Permalink
On 20 May, 23:09, "Herfried K. Wagner [MVP]" <hirf-spam-me-
Post by SMJT
Has anyone noticed that if you double click a label, the text of that
label appears on the clipboard?  If so, how do I stop this from
happening?
Yes, I am able to reproduce this behavior.  However, I am not sure if it is
by design or not.
--
 M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
 V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Thank you for trying this. I was beginning to think that it was my VS
installation or something.
frustratedclipboard
2008-05-29 15:04:03 UTC
Permalink
This happens in VS2005 SP1 on Vista SP1 too.

What an odd feature...
Post by SMJT
Hi
Has anyone noticed that if you double click a label, the text of that
label appears on the clipboard? If so, how do I stop this from
happening?
I'm running VS 2008 on a Vista box. I get the same behaviour on
another Vista machine but not on XP machines so I'm pretty sure my VS
installation is okay but just need to check.
Thanks in advance
SMJT
2008-05-30 07:43:32 UTC
Permalink
Just in case anyone else anyone else wants to avoid this problem, this
is the reply I got from the MSDN forum. It may appear to be a bit
clunky but right now if it works I'm not complaining as this is
begining to cause me a major headache.

Hi SMJT2,

I performed a test base on your description and did reproduce the
problem on my side.

The reason of this problem is that the Label receives the WM_GETTEXT
message when we double click on it. To stop this behavior, we can
ignore the WM_GETTEXT message when double-clicking operation happens.

To do this, create a new class derived from the Label class and
override the WndProc method. In the override method, if the Label has
received the WM_LBUTTONDBLCLK message before it receives the
WM_GETTEXT message, we ignore the WM_GETTEXT message.

The following is a sample:

class MyLabel:Label
{
int WM_GETTEXT = 0xD;
int WM_LBUTTONDBLCLK = 0x203;
bool doubleclickflag = false;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_LBUTTONDBLCLK)
{
doubleclickflag = true;
}
if (m.Msg == WM_GETTEXT && doubleclickflag)
{
doubleclickflag = false;
return;
}
base.WndProc(ref m);
}
}

Use the derived Label on your form and you should see it prevent its
text from being copied to the Clipboard when we double click on it.

Hope this helps.
If you have any question, please feel free to let me know.


Linda
vinit kumar
2010-08-19 09:02:00 UTC
Permalink
This post might be inappropriate. Click to display it.
Loading...