Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. About Get Data from Clipboard

About Get Data from Clipboard

Scheduled Pinned Locked Moved C#
cssgraphicsdebuggingquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RafMar
    wrote on last edited by
    #1

    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.;)

    P 1 Reply Last reply
    0
    • R RafMar

      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.;)

      P Offline
      P Offline
      peaceman77
      wrote on last edited by
      #2

      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)

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups