My clipboard hell

Inane baanter or words of wisdom - you decide...
User avatar
Thoughtcat
Baaaaa!
Baaaaa!
Posts: 1637
Joined: Mon Jul 03, 2006 7:08 pm 0
Location: London UK

My clipboard hell

Post by Thoughtcat »

What causes that thing where occasionally you copy something to the clipboard, paste it somewhere, and then copy something else entirely, but when you try and paste the second thing, the first bloody thing comes out instead? Over and over again, no matter how many times you try?? :twisted: (I'm in XP.)
Last edited by Thoughtcat on Mon Jun 04, 2007 1:18 pm 0, edited 1 time in total.
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27259
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Post by gilesgoat »

Could be many things .. including the application not handling too well
the clipboard events ...
Giles the billy goat
"Baa"
User avatar
Arganoid
Baaa!
Baaa!
Posts: 238
Joined: Sat Aug 03, 2002 3:27 pm 0
Location: Cambridge, UK
Contact:

Post by Arganoid »

I often use the "Copy" menu option rather than Ctrl-C since the latter sometimes doesn't seem to work. At least when you use the menu option you can see a clear visual indication that something has happened.
User avatar
chris4500uk
Baaaaa!
Baaaaa!
Posts: 1158
Joined: Thu Feb 26, 2004 3:05 am 0
Location: Middlesbrough, UK
Contact:

Post by chris4500uk »

yeah just try and right click, sometimes ctrl + c doesn't always work
User avatar
Thoughtcat
Baaaaa!
Baaaaa!
Posts: 1637
Joined: Mon Jul 03, 2006 7:08 pm 0
Location: London UK

Post by Thoughtcat »

It seems application related - the problem comes up in Outlook and Word, but not in Excel or Notepad.

I've tried both the menu/Copy method and CTRL+C, and then menu/Paste and CTRL+V in various combinations, and it makes no difference in the troublesome apps.
User avatar
chris4500uk
Baaaaa!
Baaaaa!
Posts: 1158
Joined: Thu Feb 26, 2004 3:05 am 0
Location: Middlesbrough, UK
Contact:

Post by chris4500uk »

Reboot ? :lol:
AdemoN
Posts: 17
Joined: Thu Oct 26, 2006 12:03 pm 0
Location: Gosport

Post by AdemoN »

Re-install! :wink: :lol:
User avatar
gilesgoat
Sheepie Whore
Sheepie Whore
Posts: 27259
Joined: Wed Sep 03, 2003 7:54 am 0
Location: Monfalcone, Italy
Contact:

Post by gilesgoat »

To handle the clipboard events it's not really trivial ..

I know because I had to write some code to handle it.

Could be that somewhere in some windows or some particular places
they forgot and they have not been arsed to handle it.

It does not come "for free" and requires a bit of code to be handled ..
.. and of course .. enough "one thing left there or a pointer somewhere" and
you can make spectacular messes/explosions.

IIRC you get an event of I can't remember what that then gives you a
pointer to something that tells you the type of data that been pasted and
a pointer to a data-chunk containing what been pasted then you can filter
and decide what kind of data to accept as valid paste and what not and
then it's all up to you to decide what to do with that data.

The "cut/copy" operation I think is a bit more complex .. and can't
remember how it was going.

Of course all this goes into a messages queue, it all up to you to handle
the memory/buffers and be sure that all is properly cleared once you've
done, return the correct flags in the correct places otherwise it will
default to the "standard window procedure" and lot of other things ...

I can't remember if the text is always passed as UNICODE string and/or
if it depends on source and you have to check about that too.

It's not totally trivial really ..

[edit] - for your fun .. it's even a bit more complex than that ..

Code: Select all

		case WM_COMMAND:

			OutputDebugString ("GOT A COMMAND !\n");

			 if (LOWORD(wParam) == IDM_PASTE)
			 {
				 OutputDebugString ("PASTE EVENT !\n");

				 if (IsClipboardFormatAvailable (CF_TEXT))
				 {
				  // there's some text in the clipboard
				  if (OpenClipboard(hWnd))
				  {
					// the clipboard is open

				   HGLOBAL   hglb;
				   LPTSTR    lptstr; 

				   hglb = GetClipboardData(CF_TEXT); 
				   if (hglb != NULL) 
					{ 
					 lptstr = (LPTSTR) GlobalLock(hglb); 
					 if (lptstr != NULL) 
					  { 
						// Call the application-defined ReplaceSelection 
						// function to insert the text and repaint the 
						// window. 
 
						OutputDebugString ("Someone pasted some text shite !!\n");
						OutputDebugString (lptstr);
						OutputDebugString ("\n");

						if (NeonContext != NULL) Neon_UpdateClipboardData (NeonContext, lptstr);

						GlobalUnlock(hglb); 
					  }
					 EmptyClipboard();
				    } 
				   CloseClipboard(); 
				  }
				}
				 return 0;
			 }
		break;
Plain and simple huh ? :wink:

And this handles text only ..
Giles the billy goat
"Baa"
User avatar
Orava
Sheepie Whore
Sheepie Whore
Posts: 12698
Joined: Sat Mar 13, 2004 12:13 am 0
Location: The West Country

Re: My clipboard hell

Post by Orava »

Do you have the 'improved' clipboard in Office enabled? The one with the list on the right-hand side of the screen?
Holier than thou
User avatar
Thoughtcat
Baaaaa!
Baaaaa!
Posts: 1637
Joined: Mon Jul 03, 2006 7:08 pm 0
Location: London UK

Post by Thoughtcat »

Cheers Giles! I hope you're not going to test me on that later :)

Yep, I have the 'new' clipboard - didn't think of looking at that TBH - I've since rebooted and the problem's gone. All sorts of shit was happening before reboot - saying Word had run out of disk space and that I should save my work, and Outlook wouldn't let me complete an email. Next time I'll try the new clipboard - or just buy a Mac :)
User avatar
l1n3n01z
Baaaaa!
Baaaaa!
Posts: 1777
Joined: Tue Nov 19, 2002 12:14 pm 0
Location: Iceland
Contact:

Re: My clipboard hell

Post by l1n3n01z »

Orava wrote:'improved' clipboard

:lol: :lol: :lol:
User avatar
piku
Sheepie Whore
Sheepie Whore
Posts: 20960
Joined: Wed Apr 24, 2002 10:44 am 0
Website: Http://Www.ncot.uk
Location: Wakefield
Contact:

Re: My clipboard hell

Post by piku »

Orava wrote:Do you have the 'improved' clipboard in Office enabled? The one with the list on the right-hand side of the screen?
Agh that thing does my head in. "You have copied lots of stuff, look! Watch as the same thing is copied many times due to you getting all confused".
return (0);
User avatar
sponge
Baaaaaa!
Baaaaaa!
Posts: 3227
Joined: Sun Jul 17, 2005 9:05 am 0
Location: Twatting around in Los Angeles, California.

Re: My clipboard hell

Post by sponge »

Thoughtcat wrote:(I'm in XP.)
Ah ha! I've spotted the problem...
User avatar
XOR
Baaaa!
Baaaa!
Posts: 534
Joined: Mon May 07, 2007 2:11 pm 0
Location: Taunton

Re: My clipboard hell

Post by XOR »

Thoughtcat wrote:(I'm in XP.)
Are you that little smiley paper-clip fucker?
I need a cup of tea pls
WEBSITE
MYSPACE
Kronos

Re: My clipboard hell

Post by Kronos »

XOR wrote:
Thoughtcat wrote:(I'm in XP.)
Are you that little smiley paper-clip fucker?
Or the cute little puppy in the search window? :)
Post Reply