About Get Data from Clipboard
-
I know that I have Data in the clipboard with the DataFormat.MetafilePict. But I can't get it. My code is more or less the next: ///////////////////////////////////////////////////////////// IDataObject iData = Clipboard.GetDataObject(); if ( iData.GetDataPresent( DataFormats.MetafilePict) ) { System.Object obj; System.Drawing.Imaging.Metafile pMetafile; obj = Clipboard.GetDataObject()>GetData(System.Windows.Forms.DataFormats.MetafilePict ); } ///////////////////////////////////////////////////////// Obviusly in the Debug, I enter inside the first if condition, so the code executes but the System::Object obj can't keep the data of clipboard and keeps a undefined value after the asignation. It seems a contradiction, isn't it ? :confused: Can anybody say me anything about get MetafilePict Data from Clipboard ? Advanced Thanks, everybody.;)
-
I know that I have Data in the clipboard with the DataFormat.MetafilePict. But I can't get it. My code is more or less the next: ///////////////////////////////////////////////////////////// IDataObject iData = Clipboard.GetDataObject(); if ( iData.GetDataPresent( DataFormats.MetafilePict) ) { System.Object obj; System.Drawing.Imaging.Metafile pMetafile; obj = Clipboard.GetDataObject()>GetData(System.Windows.Forms.DataFormats.MetafilePict ); } ///////////////////////////////////////////////////////// Obviusly in the Debug, I enter inside the first if condition, so the code executes but the System::Object obj can't keep the data of clipboard and keeps a undefined value after the asignation. It seems a contradiction, isn't it ? :confused: Can anybody say me anything about get MetafilePict Data from Clipboard ? Advanced Thanks, everybody.;)
(Not saying this is your problem, but...) As written, the code you supplied will not work as you expect. You declare "System.Object obj;" inside the if() statement. Therefore as soon as you exit the block (next line) - obj is no longer a valid object. To correct this (if it isn't just a typo in your sample), move the System.Object obj; declaration before the if( Data.Get....) statement.
-
(Not saying this is your problem, but...) As written, the code you supplied will not work as you expect. You declare "System.Object obj;" inside the if() statement. Therefore as soon as you exit the block (next line) - obj is no longer a valid object. To correct this (if it isn't just a typo in your sample), move the System.Object obj; declaration before the if( Data.Get....) statement.
OK, thanks for reply, there was only an exemple. You are right, but if you proove the code with the correct order ( as you very well are saying ), you will see that doesn't work well ( The object 'obj' doesn't keep the data..). I have read in Microsoft support that there is a debug in this cases that imposibility the correct retriving some kind of Data from Clipboard, as Metafiles ( I hope that the next version of .NET will correct this cuestion.) Thank you very much Arlen :)