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.;)
public const uint CF_METAFILEPICT = 3; public const uint CF_ENHMETAFILE = 14; [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)] public static extern bool OpenClipboard(IntPtr hWndNewOwner); [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)] public static extern bool CloseClipboard(); [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)] public static extern IntPtr GetClipboardData(uint format); [DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)] public static extern bool IsClipboardFormatAvailable(uint format); br mode="hold" />
// Returns True if (Win32.OpenClipboard(new IntPtr(0))) { // Returns True if (Win32.IsClipboardFormatAvailable(Win32.CF_ENHMETAFILE)) { // Returns 0 IntPtr ptr = Win32.GetClipboardData(Win32.CF_ENHMETAFILE); if (!ptr.Equals(new IntPtr(0))) { // Never get here! :-( Metafile metafile = new Metafile(ptr,true); } } Win32.CloseClipboard(); }
br mode="hold" /> You can pass this.Handle instead of new IntPtr(0)