明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 8721|回复: 14

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

  [复制链接]
发表于 2006-6-12 20:53:00 | 显示全部楼层 |阅读模式

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

发表于 2006-7-4 19:53:00 | 显示全部楼层
望高手指点。
发表于 2006-11-5 12:01:00 | 显示全部楼层
发贴心情 
望高手指点。
发表于 2008-1-24 00:24:00 | 显示全部楼层

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

using System.Diagnostics;

加上

[DllImport("User32")]
        public extern static void mouse_event(int dwFlags, int dx, int dy, int dwData, IntPtr dwExtraInfo);

        [DllImport("User32")]
        public extern static void SetCursorPos(int x, int y);

        [DllImport("User32")]
        public extern static bool GetCursorPos(out POINT p);

        [DllImport("User32")]
        public extern static int ShowCursor(bool bShow);


        public struct POINT
        {
            public int X;
            public int Y;
        }


        [Flags]
        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);
       
         
        }


发表于 2008-1-24 00:29:00 | 显示全部楼层

模拟鼠标在屏幕 0,0坐标点击一下

AutoMouseLeftClick(0, 0);  

发表于 2008-2-27 13:22:00 | 显示全部楼层

谢谢哦

发表于 2008-7-3 22:39:00 | 显示全部楼层

请问blessli

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

发表于 2008-10-10 18:37:00 | 显示全部楼层
azbd发表于2008-7-3 22:39:00请问blessli:在CAD下显示一个无模式对话框,当鼠标离开该窗口后,如何将焦点转移至CAD主窗口?

遇到同样问题!

关注ing.

发表于 2012-6-24 12:30:14 | 显示全部楼层
遇到同样问题!

关注ing.

发表于 2012-10-21 11:06:46 | 显示全部楼层
blessli 发表于 2008-1-24 00:29
模拟鼠标在屏幕 0,0坐标点击一下AutoMouseLeftClick(0, 0);  

你好,用AutoMouseLeftClick(0, 0);   的话,会出现"内部错误:  gedit 3"这种错误。是为什么呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-3-12 10:23 , Processed in 0.271413 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表