- 积分
- 8260
- 明经币
- 个
- 注册时间
- 2005-2-21
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2009-11-17 09:05:00
|
显示全部楼层
- public class Class1
- {
- [DllImport("user32.dll")]
- static extern IntPtr SetParent(IntPtr child, IntPtr newParent);
- static UcSysMenu panSysMenu;
- [Autodesk.AutoCAD.Runtime.CommandMethod("MyMenu")]
- public void loadSysMenu()
- {
- DocumentCollection DocCollection = Application.DocumentManager;
- //文档创建事件
- DocCollection.DocumentCreated += new DocumentCollectionEventHandler(DocCollection_DocumentCreated);
- foreach (Document doc in DocCollection)
- {
- panSysMenu = new UcSysMenu();
- panSysMenu.Location = new System.Drawing.Point(31, 29);
- SetParent(panSysMenu.Handle, doc.Window.Handle);
- }
- }
- void DocCollection_DocumentCreated(object sender, DocumentCollectionEventArgs e)
- {
- panSysMenu = new UcSysMenu();
- panSysMenu.Location = new System.Drawing.Point(31, 29);
- SetParent(panSysMenu.Handle, Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Window.Handle);
- }
- }
复制代码 我的无非就是给加上了一个文档创建事件而已,这样可以实现每个CAD文档都能添加一样的控件.
|
|