using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; using Autodesk.AutoCAD.Interop; namespace WindowsFormsApplication1 { public partial class Form1 : Form { AcadApplication app; public Form1() { InitializeComponent(); } [DllImport("user32.dll", SetLastError = true)] static extern IntPtr SetParent(IntPtr child, IntPtr newParent);
[DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)] public static extern IntPtr GetParent(IntPtr hWnd); private void Form1_Load(object sender, EventArgs e) { app = (AcadApplication)Marshal.GetActiveObject("AutoCad.Application"); SetParent(new IntPtr(app.HWND), this.Handle); } } }
|