Hi
Thanks for your code. I also translated your code in C#.
using System.Runtime.InteropServices;
public class ClipboardAPI
{
[DllImport("user32.dll", EntryPoint = "OpenClipboard", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool OpenClipboard(IntPtr hWnd);
[DllImport("user32.dll", EntryPoint = "EmptyClipboard", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool EmptyClipboard();
[DllImport("user32.dll", EntryPoint = "SetClipboardData", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern IntPtr SetClipboardData(int uFormat, IntPtr hWnd);
[DllImport("user32.dll", EntryPoint = "CloseClipboard", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool CloseClipboard();
[DllImport("user32.dll", EntryPoint = "GetClipboardData", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern IntPtr GetClipboardData(int uFormat);
[DllImport("user32.dll", EntryPoint = "IsClipboardFormatAvailable", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern short IsClipboardFormatAvailable(int uFormat);
}
// ===================================================================
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
const int CF_ENHMETAFILE = 14;
IntPtr henmetafile;
System.Drawing.Imaging.Metafile metaFile = null;
if (ClipboardAPI.OpenClipboard(this.Handle))
{
if (ClipboardAPI.IsClipboardFormatAvailable(CF_ENHMETAFILE) != 0)
{
henmetafile = ClipboardAPI.GetClipboardData(CF_ENHMETAFILE);
metaFile = new System.Drawing.Imaging.Metafile(henmetafile, true);
ClipboardAPI.CloseClipboard();
}
}
try
{
builder.InsertImage(metaFile, 574.55, 487.45);
}
catch (Exception ex)
{ }
doc.Save(@"C:\Temp\out.doc");
Best regards.