Click here to Skip to main content
15,910,083 members
Home / Discussions / C#
   

C#

 
GeneralRe: Windows Forms Focus Pin
Alex Leshinsky26-Nov-04 11:09
Alex Leshinsky26-Nov-04 11:09 
GeneralRestoring Previous Clipboard Data Pin
Jay Shankar24-Nov-04 13:49
Jay Shankar24-Nov-04 13:49 
GeneralRe: Restoring Previous Clipboard Data Pin
Heath Stewart24-Nov-04 14:33
protectorHeath Stewart24-Nov-04 14:33 
GeneralRe: Restoring Previous Clipboard Data Pin
Jay Shankar24-Nov-04 23:04
Jay Shankar24-Nov-04 23:04 
GeneralRe: Restoring Previous Clipboard Data Pin
Heath Stewart25-Nov-04 5:40
protectorHeath Stewart25-Nov-04 5:40 
GeneralRe: Restoring Previous Clipboard Data Pin
Jay Shankar25-Nov-04 16:41
Jay Shankar25-Nov-04 16:41 
GeneralRe: Restoring Previous Clipboard Data Pin
Heath Stewart25-Nov-04 19:44
protectorHeath Stewart25-Nov-04 19:44 
GeneralRe: Restoring Previous Clipboard Data Pin
Jay Shankar25-Nov-04 20:48
Jay Shankar25-Nov-04 20:48 
I am really sorry for not elaborating the scenario.

Below are the details.

Steps resulting error
1. I. Open TextPad / MS Word, II. write text III. Copy the content in the clipboard

2. I. Run the C# Application II. Call the method

3.Causes Runtime eroor at Clipboard.SetDataObject(oldData) line ;

4. Error Details :
System.Runtime.InteropServices.ExternalException : The requested clipboard operation failed.



Code :
private void PasteImg(RichTextBox richTextBox1, string imageFileName)
{
	//Copy the previous clipped data
	IDataObject oldData = Clipboard.GetDataObject();



	#region Pasting the image
	if("" == imageFileName) imageFileName = @"c:\JayShared\music.bmp";


	Bitmap myBitmap = new Bitmap(imageFileName);

	// Copy the bitmap to the clipboard.
	Clipboard.SetDataObject(myBitmap, false);

	// Get the format for the object type.
	DataFormats.Format myFormat = DataFormats.GetFormat (DataFormats.Bitmap);

	// After verifying that the data can be pasted, paste
	if(richTextBox1.CanPaste(myFormat)) 
	{
		richTextBox1.Paste();
	}


	#endregion Pasting the image

	//
	//paste back the previous clipped data to the clipboard

	Clipboard.SetDataObject(oldData); //.......... Error occurs here.........


	//
}

GeneralRe: Restoring Previous Clipboard Data Pin
Dennis C. Dietrich24-Nov-04 14:35
Dennis C. Dietrich24-Nov-04 14:35 
GeneralRe: Restoring Previous Clipboard Data Pin
Jay Shankar24-Nov-04 23:06
Jay Shankar24-Nov-04 23:06 
GeneralDynamic Classes and Intellisense Pin
tteta@visioncore.com24-Nov-04 13:00
tteta@visioncore.com24-Nov-04 13:00 
GeneralRe: Dynamic Classes and Intellisense Pin
leppie25-Nov-04 1:38
leppie25-Nov-04 1:38 
GeneralRe: Dynamic Classes and Intellisense Pin
Heath Stewart25-Nov-04 19:41
protectorHeath Stewart25-Nov-04 19:41 
General[Easy] Remoting Pin
Snowjim24-Nov-04 12:52
Snowjim24-Nov-04 12:52 
GeneralRe: [Easy] Remoting Pin
Snowjim24-Nov-04 22:36
Snowjim24-Nov-04 22:36 
Generalquickest and easiest way to share data (C dll & .net dll) Pin
Anonymous24-Nov-04 11:03
Anonymous24-Nov-04 11:03 
GeneralRe: quickest and easiest way to share data (C dll & .net dll) Pin
Nick Parker24-Nov-04 11:08
protectorNick Parker24-Nov-04 11:08 
GeneralRe: quickest and easiest way to share data (C dll & .net dll) Pin
asaddsada24-Nov-04 11:53
sussasaddsada24-Nov-04 11:53 
Generalweb services update database using dataset Pin
Don Jonathan24-Nov-04 11:00
sussDon Jonathan24-Nov-04 11:00 
GeneralRe: web services update database using dataset Pin
Heath Stewart24-Nov-04 14:40
protectorHeath Stewart24-Nov-04 14:40 
Questiondynamic acces to class variables? Pin
TyronX24-Nov-04 8:25
TyronX24-Nov-04 8:25 
AnswerRe: dynamic acces to class variables? Pin
TyronX24-Nov-04 8:36
TyronX24-Nov-04 8:36 
GeneralRe: dynamic acces to class variables? Pin
DavidNohejl24-Nov-04 14:13
DavidNohejl24-Nov-04 14:13 
AnswerRe: dynamic acces to class variables? Pin
Heath Stewart24-Nov-04 8:55
protectorHeath Stewart24-Nov-04 8:55 
GeneralDoubleClick Event on a Label Pin
mlamb24-Nov-04 7:49
mlamb24-Nov-04 7:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.