yangxi 发表于 2006-6-12 20:53:00

c#如何激活CAD窗口(红色部分如何写)

.AcadSelectionSet sset;
         AutoCAD.AcadApplication app;
         app = (AcadApplication)      
         System.Runtime.InteropServices.Marshal.GetActiveObject("AutoCAD.Application.16");
            short[] f1 = new short[] { 2 };
            object[] f2 = new object[] { "gtmodel" };
            
            sset=app.ActiveDocument.SelectionSets.Add("MySelect");
            this.Hide();
            //此次如何激活CAD窗口,让程序在cad中选择
            
            app.ActiveDocument.Utility.Prompt("请选择对象:");
            sset.SelectOnScreen(f1, f2);
            this.Show();

tcsl9621 发表于 2006-7-4 19:53:00

望高手指点。

wz0406 发表于 2006-11-5 12:01:00


http://www.mjtd.com/bbs/skins/default/topicface/face1.gif

望高手指点。

blessli 发表于 2008-1-24 00:24:00

不知老兄是否解决问题了?我的方法比较复杂,就是模拟鼠标在CAD屏幕上点击一下。
using System.Diagnostics;
加上

      public extern static void mouse_event(int dwFlags, int dx, int dy, int dwData, IntPtr dwExtraInfo);
      
      public extern static void SetCursorPos(int x, int y);
      
      public extern static bool GetCursorPos(out POINT p);
      
      public extern static int ShowCursor(bool bShow);
      public struct POINT
      {
            public int X;
            public int Y;
      }
      
      public enum MouseEventFlags
      {
            Move = 0x0001,
            LeftDown = 0x0002,
            LeftUp = 0x0004,
            RightDown = 0x0008,
            RightUp = 0x0010,
            MiddleDown = 0x0020,
            MiddleUp = 0x0040,
            Wheel = 0x0800,
            Absolute = 0x8000
      }
//==========================================模拟鼠标左键点击
      private void AutoMouseLeftClick(int x,int y)
      {
            int dx = 0;
            int dy = 0;
            mouse_event((int)(MouseEventFlags.LeftDown | MouseEventFlags.Absolute), dx, dy, 0, IntPtr.Zero);
            mouse_event((int)(MouseEventFlags.LeftUp | MouseEventFlags.Absolute), dx, dy, 0, IntPtr.Zero);
      
         
      }

blessli 发表于 2008-1-24 00:29:00

模拟鼠标在屏幕 0,0坐标点击一下
AutoMouseLeftClick(0, 0);   

fairfanfan 发表于 2008-2-27 13:22:00

谢谢哦

azbd 发表于 2008-7-3 22:39:00

请问blessli:
在CAD下显示一个无模式对话框,当鼠标离开该窗口后,如何将焦点转移至CAD主窗口?

lntuzjc 发表于 2008-10-10 18:37:00


遇到同样问题!
关注ing.

ctgu123 发表于 2012-6-24 12:30:00

遇到同样问题!
关注ing.

yxr_MJTD 发表于 2012-10-21 11:06:00


你好,用AutoMouseLeftClick(0, 0);   的话,会出现"内部错误:gedit 3"这种错误。是为什么呢?
页: [1]
查看完整版本: c#如何激活CAD窗口(红色部分如何写)